-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sql): add view on run nodes (#5108)
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- +migrate Up | ||
CREATE VIEW view_node_run_job AS | ||
SELECT | ||
jobs->>'id' as "id", | ||
jobs->>'workflow_node_run_id' as "workflow_node_run_id", | ||
jobs->>'status' as "status", | ||
cast(jobs->>'start' as timestamp with time zone) as "started", | ||
cast(jobs->>'queued' as timestamp with time zone) as "queued" , | ||
cast(jobs->>'done' as timestamp with time zone) as "done", | ||
jobs->>'retry' as "retry", | ||
jobs->>'model' as "model", | ||
jobs->>'worker_name' as "worker", | ||
jobs->>'hatchery_name' as "hatchery" | ||
FROM ( | ||
SELECT | ||
jsonb_array_elements( | ||
CASE jsonb_typeof(stages->'run_jobs') | ||
WHEN 'array' THEN stages->'run_jobs' | ||
ELSE '[]' END | ||
) jobs | ||
FROM ( | ||
SELECT | ||
jsonb_array_elements( | ||
CASE jsonb_typeof(stages) | ||
WHEN 'array' THEN stages | ||
ELSE '[]' END | ||
) stages | ||
FROM workflow_node_run | ||
) tmpStages | ||
) tmpJobs | ||
order by started desc; | ||
|
||
-- +migrate Down | ||
DROP VIEW view_node_run_job; |