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

Only include workflow runs on default branch #9

Merged
merged 1 commit into from
Apr 11, 2024
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
33 changes: 22 additions & 11 deletions pathogen-workflows.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/nextstrain/.github/pull/54>. —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
;