Skip to content

api: add opt-in totals to activity and collection lists - #98

Merged
Kzoeps merged 3 commits into
mainfrom
api/tech-913-total-count
Nov 24, 2026
Merged

Kzoeps merged 3 commits into
mainfrom
api/tech-913-total-count

Conversation

@Kzoeps

@Kzoeps Kzoeps commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes TECH-913.

Problem

Clients cannot get the total number of matching activities or collections from a paginated response.

Fix

Add includeTotal=true to return an exact count across all matching records before pagination. Default list behavior and search endpoints stay unchanged.

Summary by CodeRabbit

  • New Features
    • Activity and collection list requests can now opt in to an exact totalCount for matching records. The count reflects all filters before cursor and page limits, remains available on empty pages, and is omitted by default.
  • Documentation
    • Updated API references to describe the new option and count behavior.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api-endpoints Ready Ready Preview Nov 24, 2026 9:50am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d30ce9a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hypercerts-org/happyview-modules Minor
@hypercerts-org/api Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Activity and collection list operations now accept includeTotal to return the exact count matching the filters before cursor and limit. Counts can be returned for empty pages. The option defaults to false and is not accepted by search requests.

Changes: Activity and collection totals

Layer / File(s) Summary
Define the total-count contract
packages/api/src/lexicons/..., happyview-modules/lexicons/..., docs/sources/lexicons/..., docs/openapi.json, .agents/skills/hypercerts-api/references/..., docs/test/presentation.test.mjs, happyview-modules/tests/unit/tooling/*, .changeset/quiet-lists-counts.md
Schemas define optional includeTotal and nonnegative totalCount fields for activity and collection lists. Documentation describes the count and its behavior. Contract tests check the list schemas and confirm that search schemas do not expose the option.
Count filtered records before pagination
happyview-modules/lua/shared/activityList.lua, happyview-modules/lua/shared/collectionList.lua, happyview-modules/lua/endpoints/listActivities.lua, happyview-modules/lua/endpoints/listCollections.lua, happyview-modules/lua/endpoints/searchActivities.lua, happyview-modules/lua/endpoints/searchCollections.lua
List flows parse includeTotal, count matching records before cursor pagination, validate counts, and return totalCount when requested. Search requests continue to reject the option.
Verify count behavior and edge cases
happyview-modules/tests/http/*, happyview-modules/tests/unit/list-golden/*
HTTP and golden tests cover filtered and paged totals, empty pages, omitted totals, invalid parameters and counts, and search endpoint rejection. Golden fixtures also cover listBadgeAwards.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant listActivities
  participant activity_query
  participant ActivitySQL
  Client->>listActivities: Request includeTotal
  listActivities->>activity_query: Pass filters and include_total
  activity_query->>ActivitySQL: Count filtered records and fetch cursor page
  ActivitySQL-->>activity_query: Return count and page rows
  activity_query-->>listActivities: Return activities, cursor, and total_count
  listActivities-->>Client: Return response with totalCount
Loading

Suggested reviewers: kristoferlund

Merge Risk: Minimal · up to d30ce

This adds an optional includeTotal parameter that returns an exact total for activity and collection lists. Default behavior and search endpoints are unchanged. The tests cover totals across pages, empty pages, invalid input and invalid counts. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "api: add opt-in totals to activity and collection lists" matches the main change. The PR adds an opt-in includeTotal parameter that returns an exact totalCount for listActivities and listCo…
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.
Full details: Title check

Explanation

The title "api: add opt-in totals to activity and collection lists" matches the main change. The PR adds an opt-in includeTotal parameter that returns an exact totalCount for listActivities and listCollections. The objectives state the same intent, and the summaries show the change across the lexicons, OpenAPI docs, Lua endpoints, and tests. The title is concise and specific. It uses the "api:" prefix, which is a minor style point and does not affect the assessment.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e18ac72a-3ed2-41a1-8a36-683850b0dbb5
Commits

Reviewing files that changed from the base of the PR and between 5ac54b5 and d30ce9a.

Files selected for processing: 25

  • .agents/skills/hypercerts-api/references/endpoint-map.md
  • .agents/skills/hypercerts-api/references/openapi.json
  • .agents/skills/hypercerts-api/references/request-patterns.md
  • .changeset/quiet-lists-counts.md
  • docs/openapi.json
  • docs/sources/lexicons/org.hypercerts.claim.listActivities.json
  • docs/sources/lexicons/org.hypercerts.collection.listCollections.json
  • docs/test/presentation.test.mjs
  • happyview-modules/lexicons/org.hypercerts.claim.listActivities.json
  • happyview-modules/lexicons/org.hypercerts.collection.listCollections.json
  • happyview-modules/lua/endpoints/listActivities.lua
  • happyview-modules/lua/endpoints/listCollections.lua
  • happyview-modules/lua/endpoints/searchActivities.lua
  • happyview-modules/lua/endpoints/searchCollections.lua
  • happyview-modules/lua/shared/activityList.lua
  • happyview-modules/lua/shared/collectionList.lua
  • happyview-modules/tests/http/activity.http.test.js
  • happyview-modules/tests/http/listCollections.http.test.js
  • happyview-modules/tests/unit/list-golden/fixtures.js
  • happyview-modules/tests/unit/list-golden/list-endpoints.golden.jsonl
  • happyview-modules/tests/unit/list-golden/list-endpoints.test.js
  • happyview-modules/tests/unit/tooling/activity.test.js
  • happyview-modules/tests/unit/tooling/collection.test.js
  • packages/api/src/lexicons/org/hypercerts/claim/listActivities.defs.ts
  • packages/api/src/lexicons/org/hypercerts/collection/listCollections.defs.ts

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

@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@Kzoeps
Kzoeps merged commit ea46751 into main Nov 24, 2026
10 of 11 checks passed
@Kzoeps
Kzoeps deleted the api/tech-913-total-count branch November 24, 2026 15:43
@hypercerts-release-bot hypercerts-release-bot Bot mentioned this pull request Nov 24, 2026

This branch was successfully deployed

1 active deployment
Preview — d30ce9aa Deployed Nov 24, 2026 by vercel[bot]
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