本文整理汇总了Python中mkt.reviewers.models.ReviewerScore.get_recent方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.get_recent方法的具体用法?Python ReviewerScore.get_recent怎么用?Python ReviewerScore.get_recent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.reviewers.models.ReviewerScore
的用法示例。
在下文中一共展示了ReviewerScore.get_recent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reviewers_score_bar
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_recent [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_get_recent
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_recent [as 别名]
def test_get_recent(self):
user2 = UserProfile.objects.get(email='[email protected]')
self._give_points()
time.sleep(1) # Wait 1 sec so ordering by created is checked.
self._give_points()
self._give_points(user=user2)
scores = ReviewerScore.get_recent(self.user)
eq_(len(scores), 2)
eq_(scores[0].score, amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
eq_(scores[1].score, amo.REVIEWED_SCORES[amo.REVIEWED_WEBAPP_HOSTED])
示例3: test_caching
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_recent [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: reviewers_score_bar
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_recent [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)
)
)