當前位置: 首頁>>代碼示例>>Python>>正文


Python User.all_users方法代碼示例

本文整理匯總了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)
開發者ID:Mic92,項目名稱:mygpo,代碼行數:41,代碼來源:update-suggestions.py


注:本文中的mygpo.users.models.User.all_users方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。