Skip to content

Adding the runs_jobs_detail_aggregation endpoint - #243

Merged
tmikula-dev merged 12 commits into
masterfrom
feature/116-adding-dashboard-aggregated-query
Nov 11, 2026
Merged

tmikula-dev merged 12 commits into
masterfrom
feature/116-adding-dashboard-aggregated-query

Conversation

@tmikula-dev

@tmikula-dev tmikula-dev commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

This pull request introduces support for window-wide aggregation queries alongside existing paginated named queries, with a focus on the new runs_jobs_detail_aggregation endpoint. It updates the OpenAPI spec, handler validation, query registry, and reader logic to support aggregation queries with a new response shape, and introduces new data models for typed aggregation results.

Release Notes

  • Added a new  runs_jobs_detail_aggregation  named-query endpoint providing window-wide summary aggregates plus hourly/daily timeline buckets for runs/jobs data.

Related

#116
https://github.com/absa-group/cps-eventbus-gateway/pull/191

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

coderabbitai Bot commented Oct 20, 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 81065e8b-539d-402d-82fa-049682a6e13d
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@tmikula-dev tmikula-dev linked an issue Oct 20, 2026 that may be closed by this pull request

@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.

solid piece of work, thx, just minor comments and questions

Comment thread src/readers/sql/named_queries.sql Resolved
Comment thread src/readers/reader_postgres.py Resolved
Comment thread src/handlers/handler_named_query.py Resolved
Comment thread Dockerfile Resolved
Comment thread src/readers/reader_postgres.py Resolved
Comment thread src/readers/sql/aggregation_queries.sql Resolved

@lsulak lsulak left a comment

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.

Reviewed most of it. Good job, but I noticed several things to improve. Also, when do you anticipate we should remove the stats named queries? They are basically a duplicates of the other ones in named_queries.sql - my recommendation is either now & a ticket (probably preferable to keep PRs small scoped)

Comment thread src/readers/sql/aggregation_queries.sql Resolved
Comment thread src/readers/sql/named_queries.sql Resolved
Comment thread src/readers/sql/aggregation_queries.sql Resolved
Comment thread src/utils/utils.py
return _build_json_response(
200,
{
"success": True,

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.

hmm this is a bit weird contract, success is quite visible from the status code, and then also status code is there twice. Is there any situation when it differentiates?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I completely see what you are saying. However this contract was established in the past. And this PR is only a refactor - not creating anything new. So modification in this PR would change the established client contract and that is IMO not a current scope of this task. We can discuss it further and create from this comment a follow-up GH issue. What do you think?

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.

Agree, then maybe create a ticket to revisit this, and do it (if ever) outside of this PR

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The issue based on this conversation was created here: #256

timeline_daily_sql_key: str


SUPPORTED_AGGREGATION_QUERIES: dict[str, AggregationQuery] = {

@lsulak lsulak Oct 26, 2026 •

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.

hmm this really looks comlicated, the whole file. Isn't there already some native aiosql capability to list supported queries? Also, maybe it makes sense to split the existing queries into 2 files, i.e. 2 categories - like job detail type queries and then analytical / aggregation like queries

Update: I could not find it quickly in the aiosql docs so I just opened aiosql code and found this as a public property that you can hopefully use: available_queries against your query, for example when you are doing this: aiosql.from_path(_SQL_DIR, "psycopg2"))

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.

Also the naming is not really explanatory. This is a typical SW development process - we started with named queries, then created data structures and algorithms (loading process, validation etc) around that, and then there was a new type, more analytical queries, and now there are new data structures and algorithms around that - but basically everything is a named query, right? So the names are not descriptive enough. This is technical debt. Not to mention that stats.sql are now duplicated.

I think that this PR is a good time to reduce tech debt, not add much more to it

@tmikula-dev tmikula-dev Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I tried to make naming conventions better to current query state. See following commit: 4efa108.

I am also implementing suggested approach of aiosql available_queries. Thanks for raising that! But I want to have that in separate PR - I am about to build that on top of this PR. Following PR: #251. The solution is robust and solves several issues that we would face in the future, but for current solution maybe too complex. Share your thoughts please on the added link there.

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.

Ok, thank you, I like it :)



@dataclass(frozen=True)
class AggregationQueryParams:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

At some point, we may want to support filtering by tenant and source (and possibly other parameters as requirements emerge). If it’s a simple change, we can add it within this PR... otherwise, it can done in a separate PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Please see my response to similar comment from @lsulak: #243 (comment). The implementation is done in commit: d17382a.

@tmikula-dev

tmikula-dev commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Reviewed most of it. Good job, but I noticed several things to improve. Also, when do you anticipate we should remove the stats named queries? They are basically a duplicates of the other ones in named_queries.sql - my recommendation is either now & a ticket (probably preferable to keep PRs small scoped)

I completely feel, what you are saying or what I feel from the review points. I tried to make the solution more "friendly" by renaming the queries as described in the comment responses. But you are also suggesting some things, that are more on a refactor level or ready to be deeper discussion. If we want to start some better refactored, modifying some contracts etc lets move to follow-up issue and close this one (if possible and good enough) as a v1. Please share your thoughts.

@tmikula-dev
tmikula-dev added this pull request to stack #252 November 4, 2026 11:06
@tmikula-dev
tmikula-dev merged commit 641244d into master Nov 11, 2026
10 checks passed
@tmikula-dev
tmikula-dev deleted the feature/116-adding-dashboard-aggregated-query branch November 11, 2026 10:23
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

4 participants