1 from mygpo
.users
.models
import EpisodeUserState
2 from mygpo
.maintenance
.management
.changescmd
import ChangesCommand
3 from mygpo
.db
.couchdb
import get_userdata_database
4 from mygpo
.db
.couchdb
.episode
import episode_by_id
, set_episode_listeners
5 from mygpo
.db
.couchdb
.episode_state
import episode_listener_count
8 class Command(ChangesCommand
):
11 super(Command
, self
).__init
__('episode-toplist-status',
12 'Episode-Toplist-Update')
14 def handle_obj(self
, seq
, doc
, actions
):
15 state
= EpisodeUserState
.wrap(doc
)
17 episode
= episode_by_id(state
.episode
)
20 actions
['missing'] += 1
23 listeners
= episode_listener_count(episode
)
24 updated
= set_episode_listeners(episode
, listeners
)
25 actions
['updated'] += int(updated
)
28 def get_query_params(self
):
29 return dict(include_docs
=True, filter='episode_states/has_play_events')
32 return get_userdata_database()