Skip to content

Aggregation improvements#2230

Open
s3inlc wants to merge 10 commits into
devfrom
aggregation-improvements
Open

Aggregation improvements#2230
s3inlc wants to merge 10 commits into
devfrom
aggregation-improvements

Conversation

@s3inlc

@s3inlc s3inlc commented Jun 16, 2026

Copy link
Copy Markdown
Member

This PR changes the behavior of aggregated fields on the API. By default, there will no aggregations be included anymore.

This is needed because at a lot of places where objects are retrieved, the aggregated data is not needed, and this causes a ton of unnecessary load on the queries. The frontend should request required aggregation fields when needed instead of just assuming they are there.

Also all aggregation fields are now called exactly the same as they are requested to be consistent.

NOTE: this PR can only be merged after the frontend is adapted to this.

@s3inlc s3inlc requested review from Copilot and jessevz June 17, 2026 12:00
@s3inlc s3inlc marked this pull request as ready for review June 17, 2026 12:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR makes API “aggregated” fields opt-in rather than included by default, shifting the cost of expensive aggregation queries to only the requests that explicitly ask for them. It also standardizes aggregation field names to match what clients request via aggregate[...].

Changes:

  • Introduces a generic aggregation mechanism (getAggregateFieldsets() + callbacks) and updates several endpoints (Task, TaskWrapperDisplay, Agent, PreTask) to use it.
  • Extends AbstractModelFactory::columnFilter() to support multiple columns and ordering, with added PHPUnit coverage.
  • Updates OpenAPI aggregate query examples and adjusts API tests to explicitly request needed aggregates.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/inc/utils/TaskUtils.php Adds typed task aggregation helpers (progress/timeSpent) used by API aggregates.
src/inc/apiv2/model/TaskWrapperDisplayAPI.php Reworks wrapper display aggregations into opt-in callback-based aggregates.
src/inc/apiv2/model/TaskAPI.php Replaces legacy aggregate logic with opt-in aggregate callbacks.
src/inc/apiv2/model/PreTaskAPI.php Moves auxiliaryKeyspace to opt-in aggregate callback.
src/inc/apiv2/model/ApiTokenAPI.php Adjusts aggregation merging to work with new parent aggregation behavior.
src/inc/apiv2/model/AgentAPI.php Adds opt-in crackingTime aggregate and delegates aggregation to parent.
src/inc/apiv2/common/openAPISchema.routes.php Updates aggregate parameter examples/descriptions to reflect new callback map format.
src/inc/apiv2/common/AbstractModelAPI.php Minor formatting-only change.
src/inc/apiv2/common/AbstractBaseAPI.php Implements generic aggregate handling via fieldset callback maps.
src/dba/AbstractModelFactory.php Enhances columnFilter() to allow multi-column selection and ORDER support.
ci/phpunit/dba/AbstractModelFactoryTest.php Adds tests for ordered and multi-column columnFilter().
ci/apiv2/test_task.py Updates API test to explicitly request aggregates now that defaults are removed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inc/apiv2/common/AbstractBaseAPI.php
Comment thread src/inc/apiv2/common/AbstractBaseAPI.php
Comment thread src/inc/apiv2/model/TaskWrapperDisplayAPI.php
Comment thread src/inc/apiv2/model/TaskWrapperDisplayAPI.php
Comment thread src/inc/apiv2/model/TaskWrapperDisplayAPI.php
Comment thread src/inc/apiv2/model/TaskWrapperDisplayAPI.php
Comment thread src/inc/utils/TaskUtils.php
Comment thread src/inc/apiv2/model/ApiTokenAPI.php
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