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
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;