本文整理汇总了Python中mkt.reviewers.models.ReviewerScore.get_breakdown_since方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.get_breakdown_since方法的具体用法?Python ReviewerScore.get_breakdown_since怎么用?Python ReviewerScore.get_breakdown_since使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.reviewers.models.ReviewerScore
的用法示例。
在下文中一共展示了ReviewerScore.get_breakdown_since方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: performance
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_breakdown_since [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)
示例2: test_get_breakdown_since
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import get_breakdown_since [as 别名]
def test_get_breakdown_since(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
rs = list(ReviewerScore.objects.all())
rs[0].update(created=self.days_ago(50))
breakdown = ReviewerScore.get_breakdown_since(self.user,
self.days_ago(30))
eq_(len(breakdown), 1)
eq_([b.atype for b in breakdown], [rs[1].addon.type])