Skip to content

feat(event-stats): add named-query endpoint for runs/jobs detail - #228

Open
tmikula-dev wants to merge 6 commits into
masterfrom
feature/116-aggregated-queries
Open

tmikula-dev wants to merge 6 commits into
masterfrom
feature/116-aggregated-queries

Conversation

@tmikula-dev

@tmikula-dev tmikula-dev commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Overview

Adds a new /stats/{topic_name}/query/{query_name} endpoint that executes predefined, registry-driven named queries against PostgreSQL (starting with runs_jobs_detail, reproducing the existing Qlik runs/jobs dashboard feed) with keyset pagination, alongside supporting unit/integration tests, shared response-building utilities, and several pylint/typing cleanups (duplicate-code removal, tighter Pagination typing, unused-import and config fixes).

Release Notes

  • Added /stats/{topic_name}/query/{query_name} endpoint (HandlerNamedQuery) supporting predefined named queries with keyset pagination
  • Added runs_jobs_detail named query reproducing the Qlik runs/jobs dashboard feed

Related

Closes #116
Infra Issue: https://github.com/absa-group/cps-eventbus-gateway/issues/174

@tmikula-dev tmikula-dev self-assigned this Sep 15, 2026
@tmikula-dev tmikula-dev added the enhancement New feature or request label Sep 15, 2026
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d995aa2f-f605-42f5-a4a4-aa4490241344


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tmikula-dev

Copy link
Copy Markdown
Collaborator Author

When the logic from infra PR: https://github.com/absa-group/cps-eventbus-gateway/pull/175 is deployed with this one. The endpoint can be reached via Postman and the output seems to be correct (data + pagination).

@oto-macenauer-absa oto-macenauer-absa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, I'd just add those additional queries for some flexibility

return ReaderQueries(
get_stats=queries.get_stats.sql, # pylint: disable=no-member
get_stats_with_cursor=queries.get_stats_with_cursor.sql, # pylint: disable=no-member
get_runs_jobs_detail=queries.get_runs_jobs_detail.sql, # pylint: disable=no-member

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just making sure ... the name is correct and the dynamic name does not trigger mypy?

ORDER BY j.internal_id DESC
LIMIT :lim;

-- name: get_runs_jobs_detail_with_cursor(ts_start, ts_end, cursor_id, lim)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add a aggregated query for groups of jobs by the status - "succeeded", "failed", "killed", "skipped" - status, count

Use case is: how many jobs failed for last month?

LIMIT :lim;

-- name: get_runs_jobs_detail_with_cursor(ts_start, ts_end, cursor_id, lim)
SELECT r.event_id, r.job_ref, r.tenant_id, r.source_app,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would it make sense to add a simple generic aggregate query by one column?

use cases:

  • count of jobs grouped by a source app
  • count of jobs grouped by a tenant

the output would always be two columns, one is the key, the other is the count

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventStats: compiled queries endpoint for server-side aggregations

2 participants