mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 08:30:21 +00:00
Simplify delete_forward_extremities_for_room_txn SQL
As per feedback. Signed-off-by: Jason Robinson <jasonr@matrix.org>
This commit is contained in:
parent
da16d06301
commit
49c619a9a2
1 changed files with 4 additions and 10 deletions
|
@ -35,17 +35,11 @@ class EventForwardExtremitiesStore(SQLBaseStore):
|
||||||
def delete_forward_extremities_for_room_txn(txn):
|
def delete_forward_extremities_for_room_txn(txn):
|
||||||
# First we need to get the event_id to not delete
|
# First we need to get the event_id to not delete
|
||||||
sql = """
|
sql = """
|
||||||
SELECT
|
SELECT event_id FROM event_forward_extremities
|
||||||
last_value(event_id) OVER w AS event_id
|
INNER JOIN events USING (room_id, event_id)
|
||||||
FROM event_forward_extremities
|
|
||||||
NATURAL JOIN events
|
|
||||||
WHERE room_id = ?
|
WHERE room_id = ?
|
||||||
WINDOW w AS (
|
ORDER BY stream_ordering DESC
|
||||||
PARTITION BY room_id
|
LIMIT 1
|
||||||
ORDER BY stream_ordering
|
|
||||||
range between unbounded preceding and unbounded following
|
|
||||||
)
|
|
||||||
ORDER BY stream_ordering
|
|
||||||
"""
|
"""
|
||||||
txn.execute(sql, (room_id,))
|
txn.execute(sql, (room_id,))
|
||||||
rows = txn.fetchall()
|
rows = txn.fetchall()
|
||||||
|
|
Loading…
Reference in a new issue