Skip to content

Commit

Permalink
[Podcasts] remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankoegl committed Oct 19, 2014
1 parent b94a4ff commit 8ae746c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 64 deletions.
27 changes: 0 additions & 27 deletions mygpo/db/couchdb/episode_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,6 @@ def all_episode_states(episode):
return states


@cache_result(timeout=60*60)
def episode_listener_counts(episode):
""" (Episode-Id, listener-count) tuples for episodes w/ listeners """

if not episode:
raise QueryParameterMissing('episode')

udb = get_userdata_database()
r = udb.view('listeners/by_podcast_episode',
startkey = [episode.get_id(), None, None],
endkey = [episode.get_id(), {}, {}],
group = True,
group_level = 2,
reduce = True,
stale = 'update_after',
)

return map(_wrap_listeners, r)



def get_podcasts_episode_states(podcast, user_id):
""" Returns the latest episode actions for the podcast's episodes """

Expand Down Expand Up @@ -270,12 +249,6 @@ def get_duplicate_episode_states(user, episode):
return states


def _wrap_listeners(res):
episode = res['key'][1]
listeners = res['value']
return (episode, listeners)


@cache_result(timeout=60*60)
def get_heatmap(podcast_id, episode_id, user_id):
udb = get_userdata_database()
Expand Down
40 changes: 3 additions & 37 deletions mygpo/web/views/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
from mygpo.users.models import Client
from mygpo.web.forms import SyncForm
from mygpo.decorators import allowed_methods
from mygpo.history.stats import episode_playcounts
from mygpo.web.utils import get_podcast_link_target, get_page_list, \
check_restrictions
from mygpo.db.couchdb.episode_state import get_podcasts_episode_states, \
episode_listener_counts
from mygpo.db.couchdb.episode_state import get_podcasts_episode_states

import logging
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -134,35 +134,9 @@ def get_tags(podcast, user, max_tags=50):


def episode_list(podcast, user, offset=0, limit=None):
"""
Returns a list of episodes, with their action-attribute set to the latest
action. The attribute is unsert if there is no episode-action for
the episode.
"""

listeners = dict(episode_listener_counts(podcast))
""" Returns a list of episodes """
episodes = Episode.objects.filter(podcast=podcast).all().by_released()
episodes = list(episodes.prefetch_related('slugs')[offset:offset+limit])

# if user.is_authenticated():

# prepare pre-populated data for HistoryEntry.fetch_data
# podcasts_dict = {podcast.get_id(): podcast}
# episodes_dict = dict( (episode.id, episode) for episode in episodes)

# TODO: refactor
# actions = get_podcasts_episode_states(podcast, user.profile.uuid.hex)
# actions = map(HistoryEntry.from_action_dict, actions)

# HistoryEntry.fetch_data(user, actions,
# podcasts=podcasts_dict, episodes=episodes_dict)

# episode_actions = dict( (action.episode_id, action) for action in actions)
# else:
# episode_actions = {}

# annotate_episode = partial(_annotate_episode, listeners, episode_actions)
# return map(annotate_episode, episodes)
return episodes


Expand Down Expand Up @@ -195,14 +169,6 @@ def all_episodes(request, podcast, page_size=20):
})



def _annotate_episode(listeners, episode_actions, episode):
episode.listener_count = listeners.pop(episode.get_id(), None)
episode.action = episode_actions.pop(episode.get_id(), None)
return episode



@never_cache
@login_required
def add_tag(request, podcast):
Expand Down

0 comments on commit 8ae746c

Please sign in to comment.