Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Implement no op for room stream in sync #2022

Merged
merged 4 commits into from
Mar 16, 2017
Merged

Conversation

erikjohnston
Copy link
Member

No description provided.

@@ -818,6 +831,38 @@ def handle_room_entries(room_entry):
defer.returnValue((newly_joined_rooms, newly_joined_users))

@defer.inlineCallbacks
def _have_rooms_changed(self, sync_result_builder):
"""Returns whether any rooms have changed since the sync. Must be an
incremental sync
Copy link
Contributor

@NegativeMjark NegativeMjark Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the doctring be clearer if it was written something like this?

"""Returns true if there are any new events in the rooms the user is in since the last sync
or if the user has changed membership in any room since the last sync. 
This only makes sense when calculating an incremental sync."""

@@ -274,24 +274,25 @@ 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):
Copy link
Contributor

Choose a reason for hiding this comment

The 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."""

@@ -765,6 +764,21 @@ def _generate_sync_entry_for_rooms(self, sync_result_builder, account_data_by_ro
)
sync_result_builder.now_token = now_token

# We check up front if anything has changed, if it hasn't then there is
# no point in going futher.
Copy link
Contributor

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?

Copy link
Member Author

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.

@NegativeMjark
Copy link
Contributor

Looks good codewise. I think the comments could be improved slightly but overall it looks pretty good.

@erikjohnston
Copy link
Member Author

Updated comments.

@erikjohnston erikjohnston merged commit 248eb46 into develop Mar 16, 2017
@erikjohnston erikjohnston deleted the erikj/no_op_sync branch October 26, 2017 11:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants