Aggregation improvements#2230
Open
s3inlc wants to merge 10 commits into
Open
Conversation
…d to query this efficiently
…ith multiple columns
…hardcoded string keys
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.