fix(postgres): blocker-changed marks only the org whose resource changed (#1839)
This commit is contained in:
3 files changed
+10
-5
No files matched your search
@@ -869,14 +869,19 @@ func (q *Queries) LockTaskStatus(ctx context.Context, id int64) (string, error)
|
||||
const markBlockerChanged = `-- name: MarkBlockerChanged :execrows
|
||||
UPDATE tasks
|
||||
SET park_reason = park_reason || ' [blocker changed]', updated_at = now()
|
||||
WHERE status = 'parked' AND park_blocker = ANY($1::text[])
|
||||
WHERE status = 'parked' AND org_id = $1 AND park_blocker = ANY($2::text[])
|
||||
AND park_reason NOT LIKE '%[blocker changed]'
|
||||
`
|
||||
|
||||
type MarkBlockerChangedParams struct {
|
||||
OrgID string
|
||||
Blockers []string
|
||||
}
|
||||
|
||||
// A parked task that names one of these blockers is flagged once, so the
|
||||
// operator sees the resource it waited on was edited; retry stays theirs.
|
||||
func (q *Queries) MarkBlockerChanged(ctx context.Context, blockers []string) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, markBlockerChanged, blockers)
|
||||
func (q *Queries) MarkBlockerChanged(ctx context.Context, arg MarkBlockerChangedParams) (int64, error) {
|
||||
result, err := q.db.Exec(ctx, markBlockerChanged, arg.OrgID, arg.Blockers)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -336,5 +336,5 @@ RETURNING *;
|
||||
-- operator sees the resource it waited on was edited; retry stays theirs.
|
||||
UPDATE tasks
|
||||
SET park_reason = park_reason || ' [blocker changed]', updated_at = now()
|
||||
WHERE status = 'parked' AND park_blocker = ANY(sqlc.arg(blockers)::text[])
|
||||
WHERE status = 'parked' AND org_id = sqlc.arg(org_id) AND park_blocker = ANY(sqlc.arg(blockers)::text[])
|
||||
AND park_reason NOT LIKE '%[blocker changed]';
|
||||
@@ -147,7 +147,7 @@ func (s *Resources) PutResource(ctx context.Context, write storecontract.Resourc
|
||||
return storecontract.Resource{}, err
|
||||
}
|
||||
if blockers := blockersFixedBy(write.Kind); len(blockers) > 0 {
|
||||
if _, err := queries.MarkBlockerChanged(ctx, blockers); err != nil {
|
||||
if _, err := queries.MarkBlockerChanged(ctx, postgresdb.MarkBlockerChangedParams{OrgID: write.OrgID, Blockers: blockers}); err != nil {
|
||||
return storecontract.Resource{}, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user