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 | 40 | |
41 | 41 | |
42 | 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 | 47 | latest_results = [] |
44 | - count_types = cache.get('home_chart') | |
45 | 48 | populate_count_types = False |
46 | 49 | |
47 | 50 | if count_types is None: |
48 | 51 | populate_count_types = True |
49 | 52 | count_types = OrderedDict() |
50 | - visible_threads = get_visible_threads(logged_user) | |
53 | + visible_threads = get_visible_threads(logged_user, filter_by_user) | |
51 | 54 | count_types[_('Emails')] = len(visible_threads) |
52 | 55 | |
53 | 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 | 92 | count_types[verbose_name] = elements_count |
90 | 93 | |
91 | 94 | if populate_count_types: |
92 | - cache.set('home_chart', count_types, 30) | |
95 | + cache.set(cache_key, count_types, 30) | |
93 | 96 | |
94 | 97 | return latest_results, count_types | ... | ... |