Commit 1d66135acebfdb2b23ad36dd5b53be49197971ce
1 parent
3d0b8c3f
Exists in
master
and in
31 other branches
Fixed pep8
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
colab/search/utils.py
| ... | ... | @@ -40,8 +40,11 @@ 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'+getattr(filter_by_user, "username", "")) | |
| 45 | 48 | populate_count_types = False |
| 46 | 49 | |
| 47 | 50 | if count_types is None: |
| ... | ... | @@ -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'+getattr(filter_by_user, "username", ""), count_types, 30) | |
| 95 | + cache.set(cache_key, count_types, 30) | |
| 93 | 96 | |
| 94 | 97 | return latest_results, count_types | ... | ... |