File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,19 @@ async def subscribe(self):
149149 async with await AsyncConnection .connect (self .url , autocommit = True ) as conn :
150150 async with conn .cursor () as cursor :
151151 # preprocess all rows that might be there
152+ async for row in await cursor .execute (sql .SQL ("""
153+ WITH to_delete AS (
154+ SELECT id
155+ FROM {table}
156+ WHERE guild_id = %s
157+ AND node = %s
158+ ORDER BY id
159+ )
160+ DELETE FROM {table}
161+ WHERE id IN (SELECT id FROM to_delete)
162+ RETURNING id
163+ """ ).format (table = sql .Identifier (self .name )), (self .node .guild_id , self .node .name )):
164+ self .read_queue .put_nowait (row ['id' ])
152165 await cursor .execute (sql .SQL ("LISTEN {table}" ).format (table = sql .Identifier (self .name )))
153166 gen = conn .notifies ()
154167 async for n in gen :
You can’t perform that action at this time.
0 commit comments