Commit 8473d2560516f4e7dc78bc8b9030f58f317280ed
Exists in
master
and in
31 other branches
Merge branch 'fix_cache_count' into 'master'
Fix cache count Fix the email count on profile page. Fix using same cache of a profile page after accessing a profile page of another user. See merge request !73
Showing
1 changed file
with
6 additions
and
3 deletions
Show diff stats
colab/search/utils.py
@@ -40,14 +40,17 @@ def get_visible_threads(logged_user, filter_by_user=None): | @@ -40,14 +40,17 @@ def get_visible_threads(logged_user, filter_by_user=None): | ||
40 | 40 | ||
41 | 41 | ||
42 | def get_collaboration_data(logged_user, filter_by_user=None): | 42 | def get_collaboration_data(logged_user, filter_by_user=None): |
43 | + username = getattr(filter_by_user, 'username', '') | ||
44 | + cache_key = 'home_chart-{}'.format(username) | ||
45 | + count_types = cache.get(cache_key) | ||
46 | + | ||
43 | latest_results = [] | 47 | latest_results = [] |
44 | - count_types = cache.get('home_chart') | ||
45 | populate_count_types = False | 48 | populate_count_types = False |
46 | 49 | ||
47 | if count_types is None: | 50 | if count_types is None: |
48 | populate_count_types = True | 51 | populate_count_types = True |
49 | count_types = OrderedDict() | 52 | count_types = OrderedDict() |
50 | - visible_threads = get_visible_threads(logged_user) | 53 | + visible_threads = get_visible_threads(logged_user, filter_by_user) |
51 | count_types[_('Emails')] = len(visible_threads) | 54 | count_types[_('Emails')] = len(visible_threads) |
52 | 55 | ||
53 | messages = get_visible_threads(logged_user, filter_by_user) | 56 | messages = get_visible_threads(logged_user, filter_by_user) |
@@ -89,6 +92,6 @@ def get_collaboration_data(logged_user, filter_by_user=None): | @@ -89,6 +92,6 @@ def get_collaboration_data(logged_user, filter_by_user=None): | ||
89 | count_types[verbose_name] = elements_count | 92 | count_types[verbose_name] = elements_count |
90 | 93 | ||
91 | if populate_count_types: | 94 | if populate_count_types: |
92 | - cache.set('home_chart', count_types, 30) | 95 | + cache.set(cache_key, count_types, 30) |
93 | 96 | ||
94 | return latest_results, count_types | 97 | return latest_results, count_types |