Skip to content

Commit

Permalink
feat(sql): add view on run nodes (#5108)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsamin authored Apr 7, 2020
1 parent 10bc9a3 commit add4d15
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions engine/sql/196_sql_jobs_view.sql
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;

0 comments on commit add4d15

Please sign in to comment.