本文整理汇总了Python中mygpo.users.models.User.all_users方法的典型用法代码示例。如果您正苦于以下问题:Python User.all_users方法的具体用法?Python User.all_users怎么用?Python User.all_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.users.models.User
的用法示例。
在下文中一共展示了User.all_users方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import all_users [as 别名]
def handle(self, *args, **options):
max_suggestions = options.get('max')
if options.get('username'):
users = [User.get_user(options.get('username'))]
else:
users = User.all_users()
users = filter(lambda u: u.is_active, users)
if options.get('outdated'):
users = filter(lambda u: not u.suggestions_up_to_date, users)
if options.get('max_users'):
users = users[:int(options.get('max_users'))]
total = len(users)
for n, user in enumerate(users):
suggestion = Suggestions.for_user(user)
subscribed_podcasts = list(set(user.get_subscribed_podcasts()))
subscribed_podcasts = filter(None, subscribed_podcasts)
subscribed_podcasts = filter(None, subscribed_podcasts)
related = chain.from_iterable([p.related_podcasts for p in subscribed_podcasts])
related = filter(lambda pid: not pid in suggestion.blacklist, related)
counter = Counter(related)
get_podcast_id = itemgetter(0)
suggested = map(get_podcast_id, counter.most_common(max_suggestions))
suggestion.podcasts = suggested
suggestion.save()
_update_user(user=user)
progress(n+1, total)