Remove unused receipt datastore methods. (#12632)

The last usage was removed in 5a1dd297c3 (#8059).
pull/12725/head
Patrick Cloke 2022-05-05 07:51:19 -04:00 committed by GitHub
parent cc7656099d
commit ddc8bba00f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 54 deletions

1
changelog.d/12632.misc Normal file
View File

@ -0,0 +1 @@
Remove unused code related to receipts.

View File

@ -22,7 +22,6 @@ from typing import (
Iterable,
List,
Optional,
Set,
Tuple,
cast,
)
@ -117,33 +116,6 @@ class ReceiptsWorkerStore(SQLBaseStore):
"""Get the current max stream ID for receipts stream"""
return self._receipts_id_gen.get_current_token()
@cached()
async def get_users_with_read_receipts_in_room(self, room_id: str) -> Set[str]:
receipts = await self.get_receipts_for_room(room_id, ReceiptTypes.READ)
return {r["user_id"] for r in receipts}
@cached()
async def get_receipts_for_room(
self, room_id: str, receipt_type: str
) -> List[Dict[str, Any]]:
"""
Fetch the event IDs for the latest receipt for all users in a room with the given receipt type.
Args:
room_id: The room ID to fetch the receipt for.
receipt_type: The receipt type to fetch.
Returns:
A list of dictionaries, one for each user ID. Each dictionary
contains a user ID and the event ID of that user's latest receipt.
"""
return await self.db_pool.simple_select_list(
table="receipts_linearized",
keyvalues={"room_id": room_id, "receipt_type": receipt_type},
retcols=("user_id", "event_id"),
desc="get_receipts_for_room",
)
async def get_last_receipt_event_id_for_user(
self, user_id: str, room_id: str, receipt_types: Iterable[str]
) -> Optional[str]:
@ -599,23 +571,6 @@ class ReceiptsWorkerStore(SQLBaseStore):
"get_all_updated_receipts", get_all_updated_receipts_txn
)
def _invalidate_get_users_with_receipts_in_room(
self, room_id: str, receipt_type: str, user_id: str
) -> None:
if receipt_type != ReceiptTypes.READ:
return
res = self.get_users_with_read_receipts_in_room.cache.get_immediate(
room_id, None, update_metrics=False
)
if res and user_id in res:
# We'd only be adding to the set, so no point invalidating if the
# user is already there
return
self.get_users_with_read_receipts_in_room.invalidate((room_id,))
def invalidate_caches_for_receipt(
self, room_id: str, receipt_type: str, user_id: str
) -> None:
@ -624,8 +579,6 @@ class ReceiptsWorkerStore(SQLBaseStore):
self._get_last_receipt_event_id_for_user.invalidate(
(user_id, room_id, receipt_type)
)
self._invalidate_get_users_with_receipts_in_room(room_id, receipt_type, user_id)
self.get_receipts_for_room.invalidate((room_id, receipt_type))
def process_replication_rows(
self,
@ -842,13 +795,6 @@ class ReceiptsWorkerStore(SQLBaseStore):
) -> None:
assert self._can_write_to_receipts
txn.call_after(self.get_receipts_for_room.invalidate, (room_id, receipt_type))
txn.call_after(
self._invalidate_get_users_with_receipts_in_room,
room_id,
receipt_type,
user_id,
)
txn.call_after(
self._get_receipts_for_user_with_orderings.invalidate,
(user_id, receipt_type),