Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,26 +429,28 @@ func (a *appctx) isRunCancelled(runID string, commitSha string) bool {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

stmt := spanner.Statement{
SQL: fmt.Sprintf(`SELECT run_id FROM %s
WHERE (run_id = @run_id OR commit_sha = @commit_sha)
AND status = 'closed'
LIMIT 1`, spannercanceltable),
Params: map[string]interface{}{
"run_id": runID,
"commit_sha": commitSha,
},
var stmt spanner.Statement
if runID != "" {
stmt = spanner.Statement{
SQL: fmt.Sprintf(`SELECT run_id FROM %s WHERE run_id = @run_id AND status = 'closed' LIMIT 1`, spannercanceltable),
Params: map[string]interface{}{
"run_id": runID,
},
}
} else {
stmt = spanner.Statement{
SQL: fmt.Sprintf(`SELECT run_id FROM %s WHERE commit_sha = @commit_sha AND status = 'closed' LIMIT 1`, spannercanceltable),
Params: map[string]interface{}{
"commit_sha": commitSha,
},
}
}

found := false
_ = a.spannerClient.Single().Query(ctx, stmt).Do(func(row *spanner.Row) error {
found = true
return nil
})
if found {
return true
}

return found
}

Expand Down