This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Implement no op for room stream in sync #2022
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,24 +274,27 @@ def _get_members_rows_txn(self, txn, room_id, membership=None, user_id=None): | |
|
||
return rows | ||
|
||
@cached(max_entries=500000, iterable=True) | ||
@cachedInlineCallbacks(max_entries=500000, iterable=True) | ||
def get_rooms_for_user(self, user_id): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have some docstring along the lines of: """Returns an immutable set of room_id strings for the rooms the user is joined to.""" |
||
return self.get_rooms_for_user_where_membership_is( | ||
"""Returns a set of room_ids the user is currently joined to | ||
""" | ||
rooms = yield self.get_rooms_for_user_where_membership_is( | ||
user_id, membership_list=[Membership.JOIN], | ||
) | ||
defer.returnValue(frozenset(r.room_id for r in rooms)) | ||
|
||
@cachedInlineCallbacks(max_entries=500000, cache_context=True, iterable=True) | ||
def get_users_who_share_room_with_user(self, user_id, cache_context): | ||
"""Returns the set of users who share a room with `user_id` | ||
""" | ||
rooms = yield self.get_rooms_for_user( | ||
room_ids = yield self.get_rooms_for_user( | ||
user_id, on_invalidate=cache_context.invalidate, | ||
) | ||
|
||
user_who_share_room = set() | ||
for room in rooms: | ||
for room_id in room_ids: | ||
user_ids = yield self.get_users_in_room( | ||
room.room_id, on_invalidate=cache_context.invalidate, | ||
room_id, on_invalidate=cache_context.invalidate, | ||
) | ||
user_who_share_room.update(user_ids) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe comment on what expensive operations this avoids?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like that sort of comment would get out of date quickly, and wouldn't necessarily help that much.