当前位置: 首页>>代码示例>>Python>>正文


Python ReviewerScore.get_breakdown_since方法代码示例

本文整理汇总了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)
开发者ID:petercpg,项目名称:zamboni,代码行数:49,代码来源:views.py

示例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])
开发者ID:anushbmx,项目名称:zamboni,代码行数:11,代码来源:test_models.py


注:本文中的mkt.reviewers.models.ReviewerScore.get_breakdown_since方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。