-
Couldn't load subscription status.
- Fork 242
Implemented sparse fieldsets support on the backend #1152 #1715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Eric-Wasson
commented
Oct 27, 2025
Agents overview page with sparse fieldsets applied
Tasks overview page with sparse fieldsets applied. A bit more data gets returned than requested. This is because of the aggregatedData function, which doesn't skip the non-included data yet. There was a todo-comment about that already before my commit (now on line 594 in AbstractBaseAPI.class.php). That's something that I'll improve in the future.
Task overview page with sparse fieldsets applied for 3 different types of data: task, hashlist and hashType
| } | ||
|
|
||
| // If sparse fieldsets (https://jsonapi.org/format/#fetching-sparse-fieldsets) is used, return only the requested data | ||
| if (is_array($sparseFieldsets)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to put the three if statements into a single if statement
src/inc/apiv2/model/tasks.routes.php
Outdated
| if ($keyspaceProgress >= $keyspace && $keyspaceProgress > 0) { | ||
| $status = 3; | ||
|
|
||
| if(is_array($sparseFieldsets) && array_key_exists('task', $sparseFieldsets) && in_array("searched", $sparseFieldsets['task']) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the first part of the check: " if(is_array($sparseFieldsets) && array_key_exists('task', $sparseFieldsets)". is now done twice, I would say do that part as on outer if statement, and then afterwards just check individually for "searched" and "status"
src/inc/apiv2/model/tasks.routes.php
Outdated
| elseif (count($activeAgents) > 0) { | ||
| $status = 1; | ||
|
|
||
| if(is_array($sparseFieldsets) && array_key_exists('task', $sparseFieldsets) && in_array("searched", $sparseFieldsets['task']) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "searched" here, should be "status".
|
With this code, will it be possible to simply return the entire object and only specify in the sparse fieldset that you also want some extra agregated data? If not I would suggest to use a different query structure for the aggregated data so that you can add aggregated data with just a few extra additions to your query |


