Skip to content

Commit

Permalink
server: format jobs api query
Browse files Browse the repository at this point in the history
Reformats query string for the jobs admin endpoint.

Epic: none

Release note: None
  • Loading branch information
xinhaoz committed Feb 22, 2023
1 parent e9e513d commit 3ae8a88
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions pkg/server/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2250,16 +2250,33 @@ func jobsHelper(

q := makeSQLQuery()
q.Append(`
SELECT job_id, job_type, description, statement, user_name, descriptor_ids,
case
when ` + retryRunningCondition + ` then 'retry-running'
when ` + retryRevertingCondition + ` then 'retry-reverting'
else status
end as status, running_status, created, started, finished, modified, fraction_completed,
high_water_timestamp, error, last_run, next_run, num_runs, execution_events::string, coordinator_id
FROM crdb_internal.jobs
WHERE true
`)
SELECT
job_id,
job_type,
description,
statement,
user_name,
descriptor_ids,
case
when ` + retryRunningCondition + ` then 'retry-running'
when ` + retryRevertingCondition + ` then 'retry-reverting'
else status
end as status,
running_status,
created,
started,
finished,
modified,
fraction_completed,
high_water_timestamp,
error,
last_run,
next_run,
num_runs,
execution_events::string,
coordinator_id
FROM crdb_internal.jobs
WHERE true`) // Simplifies filter construction below.
if req.Status == "retrying" {
q.Append(" AND ( ( " + retryRunningCondition + " ) OR ( " + retryRevertingCondition + " ) )")
} else if req.Status != "" {
Expand Down

0 comments on commit 3ae8a88

Please sign in to comment.