From 5153022dbcad13842e5c30c35aacfd8abd4e7c12 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Wed, 10 Apr 2024 17:07:29 -0700 Subject: [PATCH] Only include workflow runs on default branch This is my work-around to resolve https://github.com/nextstrain/status/issues/8 since I don't understand what's going on under the hood in steampipe and why the subquery filter is not executed. --- pathogen-workflows.sql | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pathogen-workflows.sql b/pathogen-workflows.sql index 4840709..ded22af 100644 --- a/pathogen-workflows.sql +++ b/pathogen-workflows.sql @@ -108,28 +108,39 @@ run as materialized ( run.head_sha as commit_id, run.head_commit->>'message' as commit_msg, - row_number() over ( - partition by - repository_full_name, - workflow_id - order by run_number desc - ) as relative_workflow_run_number + -- XXX FIXME: this correlated subquery is a hack around a steampipe issue… describe why, maybe explore a better work around. + -- This was originally in the where clause, but for some reason was not being executed as a filter + -- see https://github.com/nextstrain/status/issues/8 + head_branch = (select default_branch from repository r where r.repository_full_name = workflow.repository_full_name) as run_on_default_branch from workflow join github_actions_repository_workflow_run as run using (repository_full_name, workflow_id) where - -- XXX FIXME: this correlated subquery is a hack around a steampipe issue… describe why, maybe explore a better work around. - head_branch = (select default_branch from repository r where r.repository_full_name = workflow.repository_full_name) - and age(run.created_at) <= '90 days' + age(run.created_at) <= '90 days' and run.created_at >= '2024-02-13T21:50:28Z'::timestamptz -- When I merged . —trs +), + +default_branch_run as materialized ( + select + run.*, + row_number() over ( + partition by + repository_full_name, + workflow_id + order by workflow_run_number desc + ) as relative_workflow_run_number + from + run + where + run_on_default_branch is True ) select - json_agg(row_to_json(run)) + json_agg(row_to_json(default_branch_run)) from - run + default_branch_run where relative_workflow_run_number <= 30 ;