Skip to content

Conversation

@Eric-Wasson
Copy link

SF_agent_overview Agents overview page with sparse fieldsets applied
SF_tasks_overview 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.
SF_Tasks_with_several_SF Task overview page with sparse fieldsets applied for 3 different types of data: task, hashlist and hashType

@Eric-Wasson Eric-Wasson requested a review from jessevz October 27, 2025 13:09
@Eric-Wasson Eric-Wasson added the enhancement Enhancement of existing features / Small addition label Oct 27, 2025
@Eric-Wasson Eric-Wasson changed the title Implemented sparse fieldsets support on the backend Implemented sparse fieldsets support on the backend #1152 Oct 27, 2025
}

// If sparse fieldsets (https://jsonapi.org/format/#fetching-sparse-fieldsets) is used, return only the requested data
if (is_array($sparseFieldsets)) {
Copy link
Contributor

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

if ($keyspaceProgress >= $keyspace && $keyspaceProgress > 0) {
$status = 3;

if(is_array($sparseFieldsets) && array_key_exists('task', $sparseFieldsets) && in_array("searched", $sparseFieldsets['task']) ) {
Copy link
Contributor

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"

elseif (count($activeAgents) > 0) {
$status = 1;

if(is_array($sparseFieldsets) && array_key_exists('task', $sparseFieldsets) && in_array("searched", $sparseFieldsets['task']) ) {
Copy link
Contributor

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

@jessevz
Copy link
Contributor

jessevz commented Oct 28, 2025

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

@Eric-Wasson
Copy link
Author

Thanks for the feedback! I've fixed the things you mentioned and for the aggregated data it's now possible to query it separately:

Task_overview_with_some_aggregate Task overview without sparse fieldsets but with selected aggregated data.
Both_SF_and_aggregate Task overview with sparse fieldsets and selected aggregated data.
SF_without_aggregate Task overview with sparse fieldsets and without specifying aggregated data fields.

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

Labels

enhancement Enhancement of existing features / Small addition

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants