messages: Rename last_visible_message_id to first_visible_message_id.

This commit is contained in:
Vishnu Ks
2018-01-17 14:04:27 +00:00
committed by Greg Price
parent ff29fe07be
commit 036dc53d20
3 changed files with 6 additions and 7 deletions

View File

@@ -411,9 +411,9 @@ def flush_realm(sender: Any, **kwargs: Any) -> None:
delete_user_profile_caches(users)
# Deleting realm or updating message_visibility_limit
# attribute should clear the last_visible_message_id cache.
# attribute should clear the first_visible_message_id cache.
if kwargs.get('update_fields') is None or "message_visibility_limit" in kwargs['update_fields']:
cache_delete(realm_last_visible_message_id_cache_key(realm))
cache_delete(realm_first_visible_message_id_cache_key(realm))
if realm.deactivated:
cache_delete(realm_user_dicts_cache_key(realm.id))
@@ -425,9 +425,9 @@ def realm_alert_words_cache_key(realm):
# type: (Realm) -> Text
return u"realm_alert_words:%s" % (realm.string_id,)
def realm_last_visible_message_id_cache_key(realm):
def realm_first_visible_message_id_cache_key(realm):
# type: (Realm) -> Text
return u"realm_last_visible_message_id:%s" % (realm.string_id,)
return u"realm_first_visible_message_id:%s" % (realm.string_id,)
# Called by models.py to flush the stream cache whenever we save a stream
# object.

View File

@@ -13,7 +13,7 @@ from zerver.lib.cache import (
generic_bulk_cached_fetch,
to_dict_cache_key,
to_dict_cache_key_id,
realm_last_visible_message_id_cache_key,
realm_first_visible_message_id_cache_key,
)
from zerver.lib.request import JsonableError
from zerver.lib.stream_subscription import (
@@ -852,7 +852,7 @@ def apply_unread_message_event(user_profile: UserProfile,
# don't need to restrict messages to exactly
# message_visibility_limit. The query is also reasonably fast
# so cache misses can be managed without cron job.
@cache_with_key(realm_last_visible_message_id_cache_key, timeout=3600*4)
@cache_with_key(realm_first_visible_message_id_cache_key, timeout=3600*4)
def get_first_visible_message_id(realm: Realm) -> int:
if realm.message_visibility_limit is None:
return 0

View File

@@ -31,7 +31,6 @@ from zerver.lib.message import (
messages_for_ids,
sew_messages_and_reactions,
get_first_visible_message_id,
realm_last_visible_message_id_cache_key,
)
from zerver.lib.test_helpers import (