fix(eda): the undispatched-capture batch lists only captures an enabled binding still owes
Issue: archie-core-kfjz1
This commit is contained in:
1 parent
df20b64f62
commit
cf5674f5da
10 files changed
+49
-37
No files matched your search
@@ -1024,12 +1024,13 @@ func (q *Queries) ListSources(ctx context.Context, scopeOrg pgtype.Text) ([]Sour
|
||||
const listUndispatchedCaptures = `-- name: ListUndispatchedCaptures :many
|
||||
SELECT c.id, c.source, c.remote_addr, c.content_type, c.headers, c.body, c.authenticated, c.received_at, c.unsigned, c.event_type, c.org_id, c.workspace_id, c.delivery
|
||||
FROM captures c
|
||||
WHERE c.org_id = $1 AND c.source = ANY($2::text[])
|
||||
WHERE c.org_id = $1
|
||||
AND c.event_type <> ''
|
||||
AND (c.authenticated OR c.unsigned)
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM bindings b JOIN mappings m ON m.id = b.mapping
|
||||
WHERE b.org_id = c.org_id AND b.source = c.source AND b.status = 'armed' AND m.event_type = c.event_type
|
||||
AND b.id = ANY($2::text[])
|
||||
AND NOT EXISTS (SELECT 1 FROM binding_dispatches d WHERE d.binding = b.id AND d.delivery = c.delivery)
|
||||
)
|
||||
ORDER BY c.received_at, c.id
|
||||
@@ -1038,15 +1039,16 @@ LIMIT $3
|
||||
|
||||
type ListUndispatchedCapturesParams struct {
|
||||
OrgID string
|
||||
Sources []string
|
||||
Bindings []string
|
||||
EntryLimit int32
|
||||
}
|
||||
|
||||
// Oldest first, so sustained intake cannot starve accepted work. Only
|
||||
// dispatchable captures (signed, or from an approved unsigned source) are
|
||||
// listed: no binding ever matches the rest, so they would hold the batch.
|
||||
// dispatchable captures (signed, or from an approved unsigned source) that one
|
||||
// of the named bindings still owes a dispatch are listed: no other capture
|
||||
// would ever be dispatched, so it would hold the batch.
|
||||
func (q *Queries) ListUndispatchedCaptures(ctx context.Context, arg ListUndispatchedCapturesParams) ([]Capture, error) {
|
||||
rows, err := q.db.Query(ctx, listUndispatchedCaptures, arg.OrgID, arg.Sources, arg.EntryLimit)
|
||||
rows, err := q.db.Query(ctx, listUndispatchedCaptures, arg.OrgID, arg.Bindings, arg.EntryLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user