本文整理汇总了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)))
示例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.')
示例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)
示例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)
示例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)
示例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)
)
)
示例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])
示例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])