refactor(state): delete the unused ArmedBindingsForSource RPC and query
deploy / plan (push) Failing after 2s
deploy / gate (push) Skipped
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped

This commit is contained in:
sam committed 2026-11-09 01:22:02 +11:00
1 parent 90c7d137fb
commit 472478cf83
10 files changed
+54 -308

No files matched your search

@@ -547,23 +547,6 @@ func (s *EDA) ListBindings(ctx context.Context) ([]binding.Binding, error) {
return out, nil
}
// ArmedBindingsForSource returns the armed bindings a source can dispatch.
func (s *EDA) ArmedBindingsForSource(ctx context.Context, source string) ([]binding.Binding, error) {
rows, err := s.q.ArmedBindingsForSource(ctx, postgresdb.ArmedBindingsForSourceParams{Source: source, ScopeOrg: scopeOrg(ctx)})
if err != nil {
return nil, fmt.Errorf("edastore: list armed bindings: %w", err)
}
out := make([]binding.Binding, 0, len(rows))
for _, r := range rows {
b, err := bindingValue(postgresdb.GetBindingRow(r))
if err != nil {
return nil, err
}
out = append(out, b)
}
return out, nil
}
// UpdateBinding rewrites a binding's editable fields, bumps its version and
// drops it back to pending_approval.
func (s *EDA) UpdateBinding(ctx context.Context, b binding.Binding) error {
@@ -12,72 +12,6 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const armedBindingsForSource = `-- name: ArmedBindingsForSource :many
SELECT id, name, source, mapping, workflow, owner, repo, version, status, created_at, updated_at, filter, inputs, repo_param, org_id, workspace_id
FROM bindings WHERE source = $1 AND status = 'armed' AND ($2::text IS NULL OR org_id = $2) ORDER BY created_at DESC
`
type ArmedBindingsForSourceParams struct {
Source string
ScopeOrg pgtype.Text
}
type ArmedBindingsForSourceRow struct {
ID string
Name string
Source string
Mapping string
Workflow string
Owner string
Repo string
Version int64
Status string
CreatedAt time.Time
UpdatedAt time.Time
Filter string
Inputs string
RepoParam string
OrgID string
WorkspaceID string
}
func (q *Queries) ArmedBindingsForSource(ctx context.Context, arg ArmedBindingsForSourceParams) ([]ArmedBindingsForSourceRow, error) {
rows, err := q.db.Query(ctx, armedBindingsForSource, arg.Source, arg.ScopeOrg)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ArmedBindingsForSourceRow
for rows.Next() {
var i ArmedBindingsForSourceRow
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Source,
&i.Mapping,
&i.Workflow,
&i.Owner,
&i.Repo,
&i.Version,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
&i.Filter,
&i.Inputs,
&i.RepoParam,
&i.OrgID,
&i.WorkspaceID,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const captureRefusalSummary = `-- name: CaptureRefusalSummary :many
WITH r AS (
SELECT source, count(*) AS refused, array_agg(DISTINCT addr ORDER BY addr)::text[] AS addrs
@@ -115,10 +115,6 @@ FROM bindings WHERE id = sqlc.arg(id) AND (sqlc.narg(scope_org)::text IS NULL OR
SELECT id, name, source, mapping, workflow, owner, repo, version, status, created_at, updated_at, filter, inputs, repo_param, org_id, workspace_id
FROM bindings WHERE (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org)) ORDER BY created_at DESC;
-- name: ArmedBindingsForSource :many
SELECT id, name, source, mapping, workflow, owner, repo, version, status, created_at, updated_at, filter, inputs, repo_param, org_id, workspace_id
FROM bindings WHERE source = sqlc.arg(source) AND status = 'armed' AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org)) ORDER BY created_at DESC;
-- name: UpdateBinding :execrows
UPDATE bindings
SET name = sqlc.arg(name), source = sqlc.arg(source), mapping = sqlc.arg(mapping), filter = sqlc.arg(filter),