Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

cache: Only cache list results of QuerySets, not the QuerySet itself.

Alex Vandiver55c0e670d9ba
diff --git a/zerver/models.py b/zerver/models.py
index 611a19c1e30..a85c289b707 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -3825,9 +3825,11 @@ def get_user_by_id_in_realm_including_cross_realm(
@cache_with_key(realm_user_dicts_cache_key, timeout=3600 * 24 * 7)
def get_realm_user_dicts(realm_id: int) -> List[Dict[str, Any]]:
- return UserProfile.objects.filter(
- realm_id=realm_id,
- ).values(*realm_user_dict_fields)
+ return list(
+ UserProfile.objects.filter(
+ realm_id=realm_id,
+ ).values(*realm_user_dict_fields)
+ )
@cache_with_key(active_user_ids_cache_key, timeout=3600 * 24 * 7)
@@ -3879,7 +3881,7 @@ def get_source_profile(email: str, realm_id: int) -> Optional[UserProfile]:
@cache_with_key(bot_dicts_in_realm_cache_key, timeout=3600 * 24 * 7)
def get_bot_dicts_in_realm(realm: Realm) -> List[Dict[str, Any]]:
- return UserProfile.objects.filter(realm=realm, is_bot=True).values(*bot_dict_fields)
+ return list(UserProfile.objects.filter(realm=realm, is_bot=True).values(*bot_dict_fields))
def is_cross_realm_bot_email(email: str) -> bool: