Skip to content

refactor(api): serve hits.total as an integer - #1187

Open
PascalRepond wants to merge 1 commit into
rero:stagingfrom
PascalRepond:rep-totalhits
Open

PascalRepond wants to merge 1 commit into
rero:stagingfrom
PascalRepond:rep-totalhits

Conversation

@PascalRepond

Copy link
Copy Markdown
Contributor
  • Serve hits.total as the plain integer upstream Invenio returns, and that the projects resource already answers with, in place of the raw search engine object of the records-rest endpoints.
  • Free the clients from absorbing two shapes of the same count.
  • Drop the relation key, which carried nothing: records-rest asks the search engine for an exact count on every list endpoint, so it was always eq.
  • Part of API: harmonise hits.total to a plain integer on all search endpoints rero-ils#4220.

* Serve `hits.total` as the plain integer upstream Invenio returns, and
  that the projects resource already answers with, in place of the raw
  search engine object of the records-rest endpoints.
* Free the clients from absorbing two shapes of the same count.
* Drop the `relation` key, which carried nothing: records-rest asks the
  search engine for an exact count on every list endpoint, so it was
  always `eq`.
* Part of rero/rero-ils#4220.

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5f72d6d7-ff3e-4682-ae25-7df6183928f4

📥 Commits

Reviewing files that changed from the base of the PR and between 6f580f4 and d446075.

📒 Files selected for processing (16)
  • sonar/modules/serializers.py
  • tests/api/collections/test_collections_documents_facets.py
  • tests/api/collections/test_collections_permissions.py
  • tests/api/deposits/test_deposits_permissions.py
  • tests/api/documents/test_documents_ark.py
  • tests/api/documents/test_documents_permissions.py
  • tests/api/documents/test_documents_query.py
  • tests/api/documents/test_documents_rest.py
  • tests/api/organisations/test_organisations_permissions.py
  • tests/api/subdivisions/test_subdivisions_deposits_facets.py
  • tests/api/subdivisions/test_subdivisions_documents_facets.py
  • tests/api/subdivisions/test_subdivisions_permissions.py
  • tests/api/test_api_query.py
  • tests/api/users/test_users_permissions.py
  • tests/api/users/test_users_query.py
  • tests/ui/test_api.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

JSONSerializer.serialize_search now converts Elasticsearch’s hits.total.value into the numeric hits.total response field. Tests across API and UI search, permission, facet, query, and indexing scenarios now assert the flattened field. Expected hit counts and test scenarios remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to d4460

The API now returns numeric search totals consistently, with affected API and UI tests updated accordingly; no merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: serving hits.total as an integer.
Description check ✅ Passed The description directly explains the response-shape change, client impact, removal of relation, and related issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 16 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant