|
|
|
@ -795,9 +795,7 @@ class ReceiptsWorkerStore(SQLBaseStore): |
|
|
|
|
now - event_ts, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
await self.db_pool.runInteraction( |
|
|
|
|
"insert_graph_receipt", |
|
|
|
|
self._insert_graph_receipt_txn, |
|
|
|
|
await self._insert_graph_receipt( |
|
|
|
|
room_id, |
|
|
|
|
receipt_type, |
|
|
|
|
user_id, |
|
|
|
@ -810,9 +808,8 @@ class ReceiptsWorkerStore(SQLBaseStore): |
|
|
|
|
|
|
|
|
|
return stream_id, max_persisted_id |
|
|
|
|
|
|
|
|
|
def _insert_graph_receipt_txn( |
|
|
|
|
async def _insert_graph_receipt( |
|
|
|
|
self, |
|
|
|
|
txn: LoggingTransaction, |
|
|
|
|
room_id: str, |
|
|
|
|
receipt_type: str, |
|
|
|
|
user_id: str, |
|
|
|
@ -822,13 +819,6 @@ class ReceiptsWorkerStore(SQLBaseStore): |
|
|
|
|
) -> None: |
|
|
|
|
assert self._can_write_to_receipts |
|
|
|
|
|
|
|
|
|
txn.call_after( |
|
|
|
|
self._get_receipts_for_user_with_orderings.invalidate, |
|
|
|
|
(user_id, receipt_type), |
|
|
|
|
) |
|
|
|
|
# FIXME: This shouldn't invalidate the whole cache |
|
|
|
|
txn.call_after(self._get_linearized_receipts_for_room.invalidate, (room_id,)) |
|
|
|
|
|
|
|
|
|
keyvalues = { |
|
|
|
|
"room_id": room_id, |
|
|
|
|
"receipt_type": receipt_type, |
|
|
|
@ -840,8 +830,8 @@ class ReceiptsWorkerStore(SQLBaseStore): |
|
|
|
|
else: |
|
|
|
|
keyvalues["thread_id"] = thread_id |
|
|
|
|
|
|
|
|
|
self.db_pool.simple_upsert_txn( |
|
|
|
|
txn, |
|
|
|
|
await self.db_pool.simple_upsert( |
|
|
|
|
desc="insert_graph_receipt", |
|
|
|
|
table="receipts_graph", |
|
|
|
|
keyvalues=keyvalues, |
|
|
|
|
values={ |
|
|
|
@ -851,6 +841,11 @@ class ReceiptsWorkerStore(SQLBaseStore): |
|
|
|
|
where_clause=where_clause, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
self._get_receipts_for_user_with_orderings.invalidate((user_id, receipt_type)) |
|
|
|
|
|
|
|
|
|
# FIXME: This shouldn't invalidate the whole cache |
|
|
|
|
self._get_linearized_receipts_for_room.invalidate((room_id,)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReceiptsBackgroundUpdateStore(SQLBaseStore): |
|
|
|
|
POPULATE_RECEIPT_EVENT_STREAM_ORDERING = "populate_event_stream_ordering" |
|
|
|
|