fix(scheduling): fire a schedule's capture into its owning organisation

This commit is contained in:
sam committed 2026-10-27 10:03:29 +11:00
1 parent b705019eb8
commit 334bb8cc40
18 files changed
+77 -21

No files matched your search

@@ -522,7 +522,8 @@ const insertCapture = `-- name: InsertCapture :exec
INSERT INTO captures (id, source, remote_addr, content_type, headers, body, authenticated, received_at, unsigned, event_type, delivery, org_id, workspace_id)
SELECT $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11,
COALESCE(s.org_id, $12::text), COALESCE(s.workspace_id, $13::text)
CASE WHEN $2 = 'schedule' AND $12::text <> '' THEN $12::text ELSE COALESCE(s.org_id, $13::text) END,
COALESCE(s.workspace_id, $14::text)
FROM (SELECT 1) intake LEFT JOIN sources s ON s.path = $2
`
@@ -538,6 +539,7 @@ type InsertCaptureParams struct {
Unsigned bool
EventType string
Delivery string
ScheduleOrg string
DefaultOrg string
DefaultWorkspace string
}
@@ -556,6 +558,7 @@ func (q *Queries) InsertCapture(ctx context.Context, arg InsertCaptureParams) er
arg.Unsigned,
arg.EventType,
arg.Delivery,
arg.ScheduleOrg,
arg.DefaultOrg,
arg.DefaultWorkspace,
)
@@ -469,7 +469,7 @@ const startRequestedRuns = `-- name: StartRequestedRuns :many
UPDATE schedule_runs r SET result = 'running', started_at = $1
FROM schedules s
WHERE r.result = 'pending' AND s.id = r.schedule_id
RETURNING r.id, r.schedule_id, r.scheduled_for, s.name, s.built_in
RETURNING r.id, r.schedule_id, r.scheduled_for, s.name, s.built_in, s.owner_id
`
type StartRequestedRunsRow struct {
@@ -478,6 +478,7 @@ type StartRequestedRunsRow struct {
ScheduledFor time.Time
Name string
BuiltIn bool
OwnerID string
}
func (q *Queries) StartRequestedRuns(ctx context.Context, startedAt pgtype.Timestamptz) ([]StartRequestedRunsRow, error) {
@@ -495,6 +496,7 @@ func (q *Queries) StartRequestedRuns(ctx context.Context, startedAt pgtype.Times
&i.ScheduledFor,
&i.Name,
&i.BuiltIn,
&i.OwnerID,
); err != nil {
return nil, err
}