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], } }