Skip to content

Commit

Permalink
Core Data: Derive collection totals for unbound queries (#64772)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Aug 30, 2024
1 parent 77784ee commit d74df84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core-data/src/hooks/test/use-entity-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ describe( 'useEntityRecords', () => {
hasStarted: true,
isResolving: false,
status: 'SUCCESS',
totalItems: null,
totalPages: null,
totalItems: 3,
totalPages: 1,
} );
} );
} );
4 changes: 4 additions & 0 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ export const getEntityRecords =
};
} else {
records = Object.values( await apiFetch( { path } ) );
meta = {
totalItems: records.length,
totalPages: 1,
};
}

// If we request fields but the result doesn't contain the fields,
Expand Down
2 changes: 1 addition & 1 deletion packages/core-data/src/test/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe( 'getEntityRecords', () => {
{},
false,
undefined,
undefined
{ totalItems: 2, totalPages: 1 }
);
} );

Expand Down

0 comments on commit d74df84

Please sign in to comment.