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

Commit ddc8bba

Browse files
authored
Remove unused receipt datastore methods. (#12632)
The last usage was removed in 5a1dd29 (#8059).
1 parent cc76560 commit ddc8bba

File tree

2 files changed

+1
-54
lines changed

2 files changed

+1
-54
lines changed

changelog.d/12632.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove unused code related to receipts.

synapse/storage/databases/main/receipts.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Iterable,
2323
List,
2424
Optional,
25-
Set,
2625
Tuple,
2726
cast,
2827
)
@@ -117,33 +116,6 @@ def get_max_receipt_stream_id(self) -> int:
117116
"""Get the current max stream ID for receipts stream"""
118117
return self._receipts_id_gen.get_current_token()
119118

120-
@cached()
121-
async def get_users_with_read_receipts_in_room(self, room_id: str) -> Set[str]:
122-
receipts = await self.get_receipts_for_room(room_id, ReceiptTypes.READ)
123-
return {r["user_id"] for r in receipts}
124-
125-
@cached()
126-
async def get_receipts_for_room(
127-
self, room_id: str, receipt_type: str
128-
) -> List[Dict[str, Any]]:
129-
"""
130-
Fetch the event IDs for the latest receipt for all users in a room with the given receipt type.
131-
132-
Args:
133-
room_id: The room ID to fetch the receipt for.
134-
receipt_type: The receipt type to fetch.
135-
136-
Returns:
137-
A list of dictionaries, one for each user ID. Each dictionary
138-
contains a user ID and the event ID of that user's latest receipt.
139-
"""
140-
return await self.db_pool.simple_select_list(
141-
table="receipts_linearized",
142-
keyvalues={"room_id": room_id, "receipt_type": receipt_type},
143-
retcols=("user_id", "event_id"),
144-
desc="get_receipts_for_room",
145-
)
146-
147119
async def get_last_receipt_event_id_for_user(
148120
self, user_id: str, room_id: str, receipt_types: Iterable[str]
149121
) -> Optional[str]:
@@ -599,23 +571,6 @@ def get_all_updated_receipts_txn(
599571
"get_all_updated_receipts", get_all_updated_receipts_txn
600572
)
601573

602-
def _invalidate_get_users_with_receipts_in_room(
603-
self, room_id: str, receipt_type: str, user_id: str
604-
) -> None:
605-
if receipt_type != ReceiptTypes.READ:
606-
return
607-
608-
res = self.get_users_with_read_receipts_in_room.cache.get_immediate(
609-
room_id, None, update_metrics=False
610-
)
611-
612-
if res and user_id in res:
613-
# We'd only be adding to the set, so no point invalidating if the
614-
# user is already there
615-
return
616-
617-
self.get_users_with_read_receipts_in_room.invalidate((room_id,))
618-
619574
def invalidate_caches_for_receipt(
620575
self, room_id: str, receipt_type: str, user_id: str
621576
) -> None:
@@ -624,8 +579,6 @@ def invalidate_caches_for_receipt(
624579
self._get_last_receipt_event_id_for_user.invalidate(
625580
(user_id, room_id, receipt_type)
626581
)
627-
self._invalidate_get_users_with_receipts_in_room(room_id, receipt_type, user_id)
628-
self.get_receipts_for_room.invalidate((room_id, receipt_type))
629582

630583
def process_replication_rows(
631584
self,
@@ -842,13 +795,6 @@ def insert_graph_receipt_txn(
842795
) -> None:
843796
assert self._can_write_to_receipts
844797

845-
txn.call_after(self.get_receipts_for_room.invalidate, (room_id, receipt_type))
846-
txn.call_after(
847-
self._invalidate_get_users_with_receipts_in_room,
848-
room_id,
849-
receipt_type,
850-
user_id,
851-
)
852798
txn.call_after(
853799
self._get_receipts_for_user_with_orderings.invalidate,
854800
(user_id, receipt_type),

0 commit comments

Comments
 (0)