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