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


Python Article.get_all_contents方法代码示例

本文整理汇总了Python中wikipendium.wiki.models.Article.get_all_contents方法的典型用法代码示例。如果您正苦于以下问题:Python Article.get_all_contents方法的具体用法?Python Article.get_all_contents怎么用?Python Article.get_all_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wikipendium.wiki.models.Article的用法示例。


在下文中一共展示了Article.get_all_contents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_user_statistics_for_one_day

# 需要导入模块: from wikipendium.wiki.models import Article [as 别名]
# 或者: from wikipendium.wiki.models.Article import get_all_contents [as 别名]
def _generate_user_statistics_for_one_day(year=None, month=None, day=None):
    now = datetime(year, month, day)
    now = now.replace(tzinfo=utc)
    users_24_hours = map(
        lambda a: a.edited_by,
        Article.get_all_contents(timezone.timedelta(hours=24), now)
        )
    users_week = map(
        lambda a: a.edited_by,
        Article.get_all_contents(timezone.timedelta(weeks=1), now)
        )
    users_month = map(
        lambda a: a.edited_by,
        Article.get_all_contents(timezone.timedelta(weeks=4), now)
        )

    user_most_contributions_24_hours = next(
        iter(Counter(users_24_hours).most_common(1)), [None, 0])
    user_most_contributions_week = next(
        iter(Counter(users_week).most_common(1)), [None, 0])
    user_most_contributions_month = next(
        iter(Counter(users_month).most_common(1)), [None, 0])

    return {
        'most_contrib_24_hours': {
            'user': user_most_contributions_24_hours[0],
            'contributions': user_most_contributions_24_hours[1],
        },
        'most_contrib_week': {
            'user': user_most_contributions_week[0],
            'contributions': user_most_contributions_week[1],
        },
        'most_contrib_month': {
            'user': user_most_contributions_month[0],
            'contributions': user_most_contributions_month[1],
        }
    }
开发者ID:stianjensen,项目名称:wikipendium.no,代码行数:39,代码来源:views.py


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