当前位置: 首页>>代码示例>>Python>>正文


Python ReviewerScore.get_leaderboards方法代码示例

本文整理汇总了Python中mkt.reviewers.models.ReviewerScore.get_leaderboards方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.get_leaderboards方法的具体用法?Python ReviewerScore.get_leaderboards怎么用?Python ReviewerScore.get_leaderboards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.reviewers.models.ReviewerScore的用法示例。


在下文中一共展示了ReviewerScore.get_leaderboards方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reviewers_score_bar

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
def reviewers_score_bar(context, types=None):
    user = context.get('user')

    return new_context(dict(
        request=context.get('request'),
        mkt=mkt, settings=settings,
        points=ReviewerScore.get_recent(user),
        total=ReviewerScore.get_total(user),
        **ReviewerScore.get_leaderboards(user, types=types)))
开发者ID:psvramaraju,项目名称:zamboni,代码行数:11,代码来源:helpers.py

示例2: test_no_admins_or_staff_in_leaderboards

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
 def test_no_admins_or_staff_in_leaderboards(self):
     user2 = UserProfile.objects.get(email='[email protected]')
     self._give_points()
     self._give_points(user=user2)
     leaders = ReviewerScore.get_leaderboards(self.user)
     eq_(leaders['user_rank'], 1)
     eq_(leaders['leader_near'], [])
     eq_(leaders['leader_top'][0]['user_id'], self.user.id)
     eq_(len(leaders['leader_top']), 1)  # Only the editor is here.
     assert user2.id not in [l['user_id'] for l in leaders['leader_top']], (
         'Unexpected admin user found in leaderboards.')
开发者ID:anushbmx,项目名称:zamboni,代码行数:13,代码来源:test_models.py

示例3: test_caching

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
    def test_caching(self):
        self._give_points()

        with self.assertNumQueries(1):
            ReviewerScore.get_total(self.user)
        with self.assertNumQueries(0):
            ReviewerScore.get_total(self.user)

        with self.assertNumQueries(1):
            ReviewerScore.get_recent(self.user)
        with self.assertNumQueries(0):
            ReviewerScore.get_recent(self.user)

        with self.assertNumQueries(1):
            ReviewerScore.get_leaderboards(self.user)
        with self.assertNumQueries(0):
            ReviewerScore.get_leaderboards(self.user)

        with self.assertNumQueries(1):
            ReviewerScore.get_breakdown(self.user)
        with self.assertNumQueries(0):
            ReviewerScore.get_breakdown(self.user)

        # New points invalidates all caches.
        self._give_points()

        with self.assertNumQueries(1):
            ReviewerScore.get_total(self.user)
        with self.assertNumQueries(1):
            ReviewerScore.get_recent(self.user)
        with self.assertNumQueries(1):
            ReviewerScore.get_leaderboards(self.user)
        with self.assertNumQueries(1):
            ReviewerScore.get_breakdown(self.user)
开发者ID:anushbmx,项目名称:zamboni,代码行数:36,代码来源:test_models.py

示例4: test_get_leaderboards_last

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
 def test_get_leaderboards_last(self):
     users = []
     for i in range(6):
         users.append(UserProfile.objects.create(username='user-%s' % i))
     last_user = users.pop(len(users) - 1)
     for u in users:
         self._give_points(user=u)
     # Last user gets lower points by a moderation review.
     ReviewerScore.award_moderation_points(last_user, self.app, 1)
     leaders = ReviewerScore.get_leaderboards(last_user)
     eq_(leaders['user_rank'], 6)
     eq_(len(leaders['leader_top']), 3)
     eq_(len(leaders['leader_near']), 2)
开发者ID:anushbmx,项目名称:zamboni,代码行数:15,代码来源:test_models.py

示例5: test_get_leaderboards_last

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
 def test_get_leaderboards_last(self):
     users = []
     for i in range(6):
         users.append(user_factory())
     last_user = users.pop(len(users) - 1)
     for u in users:
         self._give_points(user=u)
     # Last user gets lower points by a moderation review.
     ReviewerScore.award_moderation_points(last_user, self.app, 1)
     leaders = ReviewerScore.get_leaderboards(last_user)
     eq_(leaders["user_rank"], 6)
     eq_(len(leaders["leader_top"]), 3)
     eq_(len(leaders["leader_near"]), 2)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:15,代码来源:test_models.py

示例6: reviewers_score_bar

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
def reviewers_score_bar(context, types=None, addon_type=None):
    user = context.get("amo_user")

    return new_context(
        dict(
            request=context.get("request"),
            amo=amo,
            settings=settings,
            points=ReviewerScore.get_recent(user, addon_type=addon_type),
            total=ReviewerScore.get_total(user),
            **ReviewerScore.get_leaderboards(user, types=types, addon_type=addon_type)
        )
    )
开发者ID:petercpg,项目名称:zamboni,代码行数:15,代码来源:helpers.py

示例7: test_get_leaderboards

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
 def test_get_leaderboards(self):
     user2 = UserProfile.objects.get(email='[email protected]')
     self._give_points()
     self._give_points()
     self._give_points(user=user2)
     leaders = ReviewerScore.get_leaderboards(self.user)
     eq_(leaders['user_rank'], 1)
     eq_(leaders['leader_near'], [])
     eq_(leaders['leader_top'][0]['rank'], 1)
     eq_(leaders['leader_top'][0]['user_id'], self.user.id)
     eq_(leaders['leader_top'][0]['total'],
         amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED] +
         amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
     eq_(leaders['leader_top'][1]['rank'], 2)
     eq_(leaders['leader_top'][1]['user_id'], user2.id)
     eq_(leaders['leader_top'][1]['total'],
         amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
开发者ID:anushbmx,项目名称:zamboni,代码行数:19,代码来源:test_models.py

示例8: test_get_leaderboards

# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_leaderboards [as 别名]
 def test_get_leaderboards(self):
     user2 = UserProfile.objects.get(email="[email protected]")
     self._give_points()
     self._give_points()
     self._give_points(user=user2)
     leaders = ReviewerScore.get_leaderboards(self.user)
     eq_(leaders["user_rank"], 1)
     eq_(leaders["leader_near"], [])
     eq_(leaders["leader_top"][0]["rank"], 1)
     eq_(leaders["leader_top"][0]["user_id"], self.user.id)
     eq_(
         leaders["leader_top"][0]["total"],
         mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED] + mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED],
     )
     eq_(leaders["leader_top"][1]["rank"], 2)
     eq_(leaders["leader_top"][1]["user_id"], user2.id)
     eq_(leaders["leader_top"][1]["total"], mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED])
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:19,代码来源:test_models.py


注:本文中的mkt.reviewers.models.ReviewerScore.get_leaderboards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。