mirror of https://github.com/zulip/zulip.git
avatar: Fix memcached query loop fetching bots.
Similar to the related issue with users, the new avatar storage had accidentally added database queries in a loop to this code path.
This commit is contained in:
parent
8e47dc73bd
commit
0990246289
|
@ -327,6 +327,7 @@ def active_user_dicts_in_realm_cache_key(realm):
|
||||||
|
|
||||||
bot_dict_fields = ['id', 'full_name', 'short_name', 'email',
|
bot_dict_fields = ['id', 'full_name', 'short_name', 'email',
|
||||||
'is_active', 'default_sending_stream__name',
|
'is_active', 'default_sending_stream__name',
|
||||||
|
'realm_id',
|
||||||
'default_events_register_stream__name',
|
'default_events_register_stream__name',
|
||||||
'default_all_public_streams', 'api_key',
|
'default_all_public_streams', 'api_key',
|
||||||
'bot_owner__email', 'avatar_source',
|
'bot_owner__email', 'avatar_source',
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ def get_owned_bot_dicts(user_profile, include_all_realm_bots_if_admin=True):
|
||||||
result = UserProfile.objects.filter(realm=user_profile.realm, is_bot=True,
|
result = UserProfile.objects.filter(realm=user_profile.realm, is_bot=True,
|
||||||
bot_owner=user_profile).values(*bot_dict_fields)
|
bot_owner=user_profile).values(*bot_dict_fields)
|
||||||
# TODO: Remove this import cycle
|
# TODO: Remove this import cycle
|
||||||
from zerver.lib.avatar import get_avatar_url
|
from zerver.lib.avatar import avatar_url_from_dict
|
||||||
|
|
||||||
return [{'email': botdict['email'],
|
return [{'email': botdict['email'],
|
||||||
'user_id': botdict['id'],
|
'user_id': botdict['id'],
|
||||||
|
@ -1388,8 +1388,7 @@ def get_owned_bot_dicts(user_profile, include_all_realm_bots_if_admin=True):
|
||||||
'default_events_register_stream': botdict['default_events_register_stream__name'],
|
'default_events_register_stream': botdict['default_events_register_stream__name'],
|
||||||
'default_all_public_streams': botdict['default_all_public_streams'],
|
'default_all_public_streams': botdict['default_all_public_streams'],
|
||||||
'owner': botdict['bot_owner__email'],
|
'owner': botdict['bot_owner__email'],
|
||||||
'avatar_url': get_avatar_url(botdict['avatar_source'], botdict['email'],
|
'avatar_url': avatar_url_from_dict(botdict),
|
||||||
botdict['avatar_version']),
|
|
||||||
}
|
}
|
||||||
for botdict in result]
|
for botdict in result]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue