From 70c89947efb6b2790a9485b338320ad66a26870b Mon Sep 17 00:00:00 2001 From: Rob Fisher Date: Mon, 21 May 2012 12:53:17 +0100 Subject: [PATCH] Add top senders to index page. Tag cloud cache now caches top senders as well. Rename it? --- mailshareapp/ajax.py | 5 +++-- mailshareapp/static/mailshare_index.js | 4 ++-- mailshareapp/tag_cloud_cache.py | 12 +++++++++++- templates/index.html | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mailshareapp/ajax.py b/mailshareapp/ajax.py index 19b6f0b..3145910 100644 --- a/mailshareapp/ajax.py +++ b/mailshareapp/ajax.py @@ -178,6 +178,7 @@ def fetch_multibar(request, selected_mails, propagate, url): @dajaxice_register def fetch_index_tag_cloud(request, team_id): dajax = Dajax() - tag_cloud = tag_cloud_cache.get_cached_tag_cloud(team_id) - dajax.add_data({'tag_cloud_html':tag_cloud}, 'update_index_tag_cloud') + stats = tag_cloud_cache.get_cached_tag_cloud(team_id) + print stats + dajax.add_data({'stats_html':stats}, 'update_index_stats') return dajax.json() diff --git a/mailshareapp/static/mailshare_index.js b/mailshareapp/static/mailshare_index.js index 58f99b1..2f09896 100644 --- a/mailshareapp/static/mailshare_index.js +++ b/mailshareapp/static/mailshare_index.js @@ -10,8 +10,8 @@ function document_ready_function() { fetch_index_tag_cloud(); } -function update_index_tag_cloud(data) { - $(".tag_cloud").html(data.tag_cloud_html); +function update_index_stats(data) { + $("#stats").html(data.stats_html); } $(document).ready(document_ready_function); diff --git a/mailshareapp/tag_cloud_cache.py b/mailshareapp/tag_cloud_cache.py index 40bc61d..3b73836 100644 --- a/mailshareapp/tag_cloud_cache.py +++ b/mailshareapp/tag_cloud_cache.py @@ -1,6 +1,7 @@ from django.conf import settings from mailshareapp.models import Mail, Contact, Tag import tags +import people import search import os import teams @@ -9,7 +10,16 @@ def _get_tag_cloud_html(team_id): team_search = search.get_team_search(team_id, 7) team_emails = team_search.get_query_set() month_search = search.get_team_search(team_id, 30) - tag_cloud_html = tags.search_results_to_tag_cloud_html(team_emails, month_search) + tag_cloud_html = '
' + tag_cloud_html += tags.search_results_to_tag_cloud_html(team_emails, month_search) + tag_cloud_html += '
' + + # it's untidy to put top senders code in the tag cloud cache like this, but it gets us + # going for now. + # TODO - tidy this up; possibly just search and replace "tag_cloud" with "index_page_stats" in this file. + tag_cloud_html += '

Top senders in the last week:

' + tag_cloud_html += people.search_results_to_top_senders_html(team_emails, month_search) + return tag_cloud_html diff --git a/templates/index.html b/templates/index.html index 9f02b17..5e80102 100644 --- a/templates/index.html +++ b/templates/index.html @@ -34,7 +34,7 @@

Mailshare

Advanced search

Tag cloud from emails in the last week:

-
+
{% autoescape off %}{{ footnote }}{% endautoescape %}