mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
bridgev2/database: add BackfillTaskQuery.GetNextForPortal method
This commit is contained in:
parent
07f0d8836a
commit
ef5eb3c9cf
1 changed files with 11 additions and 0 deletions
|
|
@ -86,6 +86,13 @@ const (
|
|||
WHERE bridge_id = $1 AND next_dispatch_min_ts < $2 AND is_done = false AND user_login_id <> ''
|
||||
ORDER BY next_dispatch_min_ts LIMIT 1
|
||||
`
|
||||
getNextBackfillQueryForPortal = `
|
||||
SELECT
|
||||
bridge_id, portal_id, portal_receiver, user_login_id, batch_count, is_done,
|
||||
cursor, oldest_message_id, dispatched_at, completed_at, next_dispatch_min_ts
|
||||
FROM backfill_task
|
||||
WHERE bridge_id = $1 AND portal_id = $2 AND portal_receiver = $3 AND is_done = false AND user_login_id <> ''
|
||||
`
|
||||
deleteBackfillQueueQuery = `
|
||||
DELETE FROM backfill_task
|
||||
WHERE bridge_id = $1 AND portal_id = $2 AND portal_receiver = $3
|
||||
|
|
@ -124,6 +131,10 @@ func (btq *BackfillTaskQuery) GetNext(ctx context.Context) (*BackfillTask, error
|
|||
return btq.QueryOne(ctx, getNextBackfillQuery, btq.BridgeID, time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func (btq *BackfillTaskQuery) GetNextForPortal(ctx context.Context, portalKey networkid.PortalKey) (*BackfillTask, error) {
|
||||
return btq.QueryOne(ctx, getNextBackfillQueryForPortal, btq.BridgeID, portalKey.ID, portalKey.Receiver)
|
||||
}
|
||||
|
||||
func (btq *BackfillTaskQuery) Delete(ctx context.Context, portalKey networkid.PortalKey) error {
|
||||
return btq.Exec(ctx, deleteBackfillQueueQuery, btq.BridgeID, portalKey.ID, portalKey.Receiver)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue