Skip to content

Commit

Permalink
Add top senders to index page. Tag cloud cache now caches top senders…
Browse files Browse the repository at this point in the history
… as well. Rename it?
  • Loading branch information
Rob Fisher committed May 21, 2012
1 parent 568ba2d commit 70c8994
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 3 additions & 2 deletions mailshareapp/ajax.py
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions mailshareapp/static/mailshare_index.js
Expand Up @@ -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);
12 changes: 11 additions & 1 deletion 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
Expand All @@ -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 = '<div id="tag_cloud" class="tag_cloud">'
tag_cloud_html += tags.search_results_to_tag_cloud_html(team_emails, month_search)
tag_cloud_html += '</div>'

# 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 += '<p>Top senders in the last week:</p>'
tag_cloud_html += people.search_results_to_top_senders_html(team_emails, month_search)

return tag_cloud_html


Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Expand Up @@ -34,7 +34,7 @@ <h1>Mailshare</h1>
<a href="advanced/">Advanced search</a>
</form>
<p>Tag cloud from emails in the last week:</p>
<div id="tag_cloud" class="tag_cloud">
<div id="stats">
</div>
{% autoescape off %}{{ footnote }}{% endautoescape %}
</body>
Expand Down

0 comments on commit 70c8994

Please sign in to comment.