Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sql): add view on run nodes #5108

Merged
merged 1 commit into from
Apr 7, 2020
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;