summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2020-06-15 09:58:55 +0100
committerBrendan Abolivier <babolivier@matrix.org>2020-06-15 09:58:55 +0100
commitfed493c5fdbce5942a7339f10693b7685dcac90a (patch)
treea6ff1b1363247a7415ca18e1b73c03e956fa7b53
parentLint (diff)
downloadsynapse-fed493c5fdbce5942a7339f10693b7685dcac90a.tar.xz
Incorporate review
-rw-r--r--synapse/storage/data_stores/main/event_push_actions.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/synapse/storage/data_stores/main/event_push_actions.py b/synapse/storage/data_stores/main/event_push_actions.py
index 382e0f61c2..b1a2804b34 100644
--- a/synapse/storage/data_stores/main/event_push_actions.py
+++ b/synapse/storage/data_stores/main/event_push_actions.py
@@ -40,15 +40,13 @@ DEFAULT_HIGHLIGHT_ACTION = [
 
 
 @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):
@@ -886,8 +884,6 @@ class EventPushActionsStore(EventPushActionsWorkerStore):
         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],
@@ -915,13 +911,13 @@ class EventPushActionsStore(EventPushActionsWorkerStore):
             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
             ],
         )
@@ -937,10 +933,10 @@ class EventPushActionsStore(EventPushActionsWorkerStore):
                     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
             ),
         )