Skip to content

feat(api): filter job statistics by group globs#7344

Open
okurz wants to merge 1 commit intoos-autoinst:masterfrom
okurz:feature/filter_job_statistics
Open

feat(api): filter job statistics by group globs#7344
okurz wants to merge 1 commit intoos-autoinst:masterfrom
okurz:feature/filter_job_statistics

Conversation

@okurz
Copy link
Copy Markdown
Member

@okurz okurz commented Apr 29, 2026

Motivation
Users need to filter out jobs in development job groups from the statistics
returned by the /api/v1/isos/job_stats endpoint, similar to what is currently
available for the /tests and /tests/overview endpoints.

Design Choices
We reused the existing groups_for_globs helper in the Iso API controller to
parse the group_glob and not_group_glob parameters. This helper provides
a list of matching job groups. We extract the group IDs and pass them to the
ScheduledProducts resultset's job_statistics method. The SQL query is then
dynamically constructed to filter by the target group IDs in the
most_recent_jobs block.

To ensure consistency with other filtered views in openQA, jobs without a
group (group_id IS NULL) are included when using only negative filters
(not_group_glob), but excluded when explicit positive filters (group_glob)
are applied.

Benefits
This enhancement gives users consistent and flexible filtering capabilities
across different endpoints, allowing them to isolate or ignore specific
environments (like "Development") and obtain more relevant job statistics.

This also helps me for qem-bot's handling of increment-approve, see
https://progress.opensuse.org/issues/198728

Motivation
Users need to filter out jobs in development job groups from the statistics
returned by the /api/v1/isos/job_stats endpoint, similar to what is currently
available for the /tests and /tests/overview endpoints.

Design Choices
We reused the existing `groups_for_globs` helper in the Iso API controller to
parse the `group_glob` and `not_group_glob` parameters. This helper provides
a list of matching job groups. We extract the group IDs and pass them to the
ScheduledProducts resultset's `job_statistics` method. The SQL query is then
dynamically constructed to filter by the target group IDs in the
`most_recent_jobs` block.

To ensure consistency with other filtered views in openQA, jobs without a
group (group_id IS NULL) are included when using only negative filters
(not_group_glob), but excluded when explicit positive filters (group_glob)
are applied.

Benefits
This enhancement gives users consistent and flexible filtering capabilities
across different endpoints, allowing them to isolate or ignore specific
environments (like "Development") and obtain more relevant job statistics.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ecb3f78) to head (e6780df).
⚠️ Report is 70 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #7344   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          419       419           
  Lines        44427     44448   +21     
=========================================
+ Hits         44427     44448   +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

if ($group_ids && @$group_ids) {
my $placeholders = join ', ', ('?') x @$group_ids;
$group_filter
= 'AND (mrj.group_id IN ('
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use IN ANY(?) and pass the IDs for this single static placeholder as array ref. At least I think this is possible with PostgreSQL. This has the great advantage of simplifying the code and then PostgreSQL always sees the same SQL code which is also more efficient. (Or two versions of the SQL code in case we still need different versions for with group IDs and for without group IDs.)

$sth->bind_param(4, $arch);
$sth->bind_param(5, $build);
$sth->execute;
$sth->execute(@binds);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binds that are always present could still be in this line, e.g.:

Suggested change
$sth->execute(@binds);
$sth->execute($distri, $version, $flavor, $arch, $build, @binds);

This way we would avoid copying the variables to an array just to copy them again when making the argument list.

(And with my other suggestion @binds would probably only contain 0 or 1 elements.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants