diff options
author | Aurélien Bompard <aurelien@bompard.org> | 2013-11-13 12:47:42 +0100 |
---|---|---|
committer | Aurélien Bompard <aurelien@bompard.org> | 2013-11-20 19:15:40 +0100 |
commit | cdf8249b4cb0a05e88c181674aa0a70f25019e00 (patch) | |
tree | dcb444f60b8dfb0be7a8f9840e18c939f608ed68 /hyperkitty/lib/view_helpers.py | |
parent | 85037f95b2b22a812938dc19aa2a9da35a6ea46f (diff) | |
download | hyperkitty-cdf8249b4cb0a05e88c181674aa0a70f25019e00.tar.gz hyperkitty-cdf8249b4cb0a05e88c181674aa0a70f25019e00.tar.xz hyperkitty-cdf8249b4cb0a05e88c181674aa0a70f25019e00.zip |
Front page redesign
Diffstat (limited to 'hyperkitty/lib/view_helpers.py')
-rw-r--r-- | hyperkitty/lib/view_helpers.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hyperkitty/lib/view_helpers.py b/hyperkitty/lib/view_helpers.py index 1187335..f7f9a44 100644 --- a/hyperkitty/lib/view_helpers.py +++ b/hyperkitty/lib/view_helpers.py @@ -170,3 +170,28 @@ def is_thread_unread(request, mlist_name, thread): > last_view_obj.view_date: unread = True return unread + + +def get_recent_list_activity(store, mlist): + """Return the number of emails posted in the last 30 days""" + begin_date, end_date = mlist.get_recent_dates() + days = daterange(begin_date, end_date) + + # Use get_messages and not get_threads to count the emails, because + # recently active threads include messages from before the start date + emails_in_month = store.get_messages(list_name=mlist.name, + start=begin_date, end=end_date) + # graph + emails_per_date = {} + # populate with all days before adding data. + for day in days: + emails_per_date[day.strftime("%Y-%m-%d")] = 0 + # now count the emails + for email in emails_in_month: + date_str = email.date.strftime("%Y-%m-%d") + if date_str not in emails_per_date: + continue # outside the range + emails_per_date[date_str] += 1 + # return the proper format for the javascript chart function + return [ {"date": d, "count": emails_per_date[d]} + for d in sorted(emails_per_date) ] |