@@ -559,7 +559,18 @@ def f(txn: LoggingTransaction) -> List[str]:
559
559
560
560
def _get_receipts_by_room_txn (
561
561
self , txn : LoggingTransaction , user_id : str
562
- ) -> List [Tuple [str , int ]]:
562
+ ) -> Dict [str , int ]:
563
+ """
564
+ Generate a map of room ID to the latest stream ordering that has been
565
+ read by the given user.
566
+
567
+ Args:
568
+ txn:
569
+ user_id: The user to fetch receipts for.
570
+
571
+ Returns:
572
+ A map of room ID to stream ordering for all rooms the user has a receipt in.
573
+ """
563
574
receipt_types_clause , args = make_in_list_sql_clause (
564
575
self .database_engine ,
565
576
"receipt_type" ,
@@ -580,7 +591,7 @@ def _get_receipts_by_room_txn(
580
591
581
592
args .extend ((user_id ,))
582
593
txn .execute (sql , args )
583
- return cast (List [Tuple [str , int ]], txn .fetchall ())
594
+ return dict ( cast (List [Tuple [str , int ]], txn .fetchall () ))
584
595
585
596
async def get_unread_push_actions_for_user_in_range_for_http (
586
597
self ,
@@ -605,12 +616,10 @@ async def get_unread_push_actions_for_user_in_range_for_http(
605
616
The list will have between 0~limit entries.
606
617
"""
607
618
608
- receipts_by_room = dict (
609
- await self .db_pool .runInteraction (
610
- "get_unread_push_actions_for_user_in_range_http_receipts" ,
611
- self ._get_receipts_by_room_txn ,
612
- user_id = user_id ,
613
- ),
619
+ receipts_by_room = await self .db_pool .runInteraction (
620
+ "get_unread_push_actions_for_user_in_range_http_receipts" ,
621
+ self ._get_receipts_by_room_txn ,
622
+ user_id = user_id ,
614
623
)
615
624
616
625
def get_push_actions_txn (
@@ -679,12 +688,10 @@ async def get_unread_push_actions_for_user_in_range_for_email(
679
688
The list will have between 0~limit entries.
680
689
"""
681
690
682
- receipts_by_room = dict (
683
- await self .db_pool .runInteraction (
684
- "get_unread_push_actions_for_user_in_range_email_receipts" ,
685
- self ._get_receipts_by_room_txn ,
686
- user_id = user_id ,
687
- ),
691
+ receipts_by_room = await self .db_pool .runInteraction (
692
+ "get_unread_push_actions_for_user_in_range_email_receipts" ,
693
+ self ._get_receipts_by_room_txn ,
694
+ user_id = user_id ,
688
695
)
689
696
690
697
def get_push_actions_txn (
0 commit comments