本文整理匯總了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],
}
}