本文整理汇总了Python中mkt.reviewers.models.ReviewerScore.get_breakdown方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.get_breakdown方法的具体用法?Python ReviewerScore.get_breakdown怎么用?Python ReviewerScore.get_breakdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.reviewers.models.ReviewerScore
的用法示例。
在下文中一共展示了ReviewerScore.get_breakdown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_breakdown
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_breakdown [as 别名]
def test_get_breakdown(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
breakdown = ReviewerScore.get_breakdown(self.user)
eq_(len(breakdown), 1)
eq_(set([b.atype for b in breakdown]),
set([amo.ADDON_WEBAPP]))
示例2: test_caching
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_breakdown [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)
示例3: performance
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_breakdown [as 别名]
def performance(request, username=None):
is_admin = acl.action_allowed(request, 'Admin', '%')
if username:
if username == request.amo_user.username:
user = request.amo_user
elif is_admin:
user = get_object_or_404(UserProfile, username=username)
else:
raise http.Http404
else:
user = request.amo_user
today = datetime.date.today()
month_ago = today - datetime.timedelta(days=30)
year_ago = today - datetime.timedelta(days=365)
total = ReviewerScore.get_total(user)
totals = ReviewerScore.get_breakdown(user)
months = ReviewerScore.get_breakdown_since(user, month_ago)
years = ReviewerScore.get_breakdown_since(user, year_ago)
def _sum(iter, types):
return sum(s.total for s in iter if s.atype in types)
breakdown = {
'month': {
'addons': _sum(months, amo.GROUP_TYPE_ADDON),
'apps': _sum(months, amo.GROUP_TYPE_WEBAPP),
},
'year': {
'addons': _sum(years, amo.GROUP_TYPE_ADDON),
'apps': _sum(years, amo.GROUP_TYPE_WEBAPP),
},
'total': {
'addons': _sum(totals, amo.GROUP_TYPE_ADDON),
'apps': _sum(totals, amo.GROUP_TYPE_WEBAPP),
}
}
ctx = context(request, **{
'profile': user,
'total': total,
'breakdown': breakdown,
})
return render(request, 'reviewers/performance.html', ctx)