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

Commit

Permalink
Incorporate review
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Jun 15, 2020
1 parent e186c66 commit fed493c
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions synapse/storage/data_stores/main/event_push_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@


@attr.s
class EventPushSummary(object):
class EventPushSummary:
"""Summary of pending event push actions for a given user in a given room."""

user_id = attr.ib()
room_id = attr.ib()
unread_count = attr.ib()
stream_ordering = attr.ib()
old_user_id = attr.ib()
notif_count = attr.ib()
unread_count = attr.ib(type=int)
stream_ordering = attr.ib(type=int)
old_user_id = attr.ib(type=str)
notif_count = attr.ib(type=int)


def _serialize_action(actions, is_highlight):
Expand Down Expand Up @@ -886,8 +884,6 @@ def _rotate_notifs_before_txn(self, txn, rotate_to_stream_ordering):
summaries = {} # type: Dict[Tuple[str, str], EventPushSummary]
for row in txn:
summaries[(row[0], row[1])] = EventPushSummary(
user_id=row[0],
room_id=row[1],
unread_count=row[2],
stream_ordering=row[3],
old_user_id=row[4],
Expand Down Expand Up @@ -915,13 +911,13 @@ def _rotate_notifs_before_txn(self, txn, rotate_to_stream_ordering):
table="event_push_summary",
values=[
{
"user_id": summary.user_id,
"room_id": summary.room_id,
"user_id": user_id,
"room_id": room_id,
"notif_count": summary.notif_count,
"unread_count": summary.unread_count,
"stream_ordering": summary.stream_ordering,
}
for summary in summaries.values()
for ((user_id, room_id), summary) in summaries.items()
if summary.old_user_id is None
],
)
Expand All @@ -937,10 +933,10 @@ def _rotate_notifs_before_txn(self, txn, rotate_to_stream_ordering):
summary.notif_count,
summary.unread_count,
summary.stream_ordering,
summary.user_id,
summary.room_id,
user_id,
room_id,
)
for summary in summaries.values()
for ((user_id, room_id), summary) in summaries.items()
if summary.old_user_id is not None
),
)
Expand Down

0 comments on commit fed493c

Please sign in to comment.