Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 4, 2025

The submitters endpoint lacked pagination, making it inefficient for clients to retrieve large datasets. This adds limit and skip query parameters and wraps the response in an object with total count.

Changes

Handler (cmd/stats/main.go)

  • Parse limit and skip using existing util.ParseLimitSkipShuffle (default: 10, max: 100)
  • Apply pagination after filtering nil submitters
  • Returns response wrapped in object with total count and results array
  • limit=0 returns all results
  • Endpoint registered at /v2/submitters (organized with submission-related endpoints)

SubmittersResult Structure (shared/people.go)

  • Added SubmittersResult with Total (int) and Results ([]Submitter)
  • Analogous to SearchResult used by programs and sequences endpoints

Tests (cmd/stats/submitters_test.go)

  • 8 test cases covering default limit, custom pagination, edge cases
  • All tests updated to expect new response structure with total and results
  • Dynamic expected counts for maintainability

API Spec (openapi.v2.yaml)

  • Added "Submissions" tag for program submission related endpoints
  • Added SubmittersResult schema definition
  • Endpoint at /submitters uses Submissions tag
  • Updated Limit component: minimum: 0 to allow unlimited results

Test Script (test.sh)

  • Updated to use new endpoint path

Response Format

{
  "total": 100,
  "results": [
    { "name": "submitter1", "numPrograms": 50 },
    { "name": "submitter2", "numPrograms": 30 }
  ]
}

Usage

# Default: first 10 submitters
GET /v2/submitters

# Custom pagination
GET /v2/submitters?limit=5&skip=10

# No limit
GET /v2/submitters?limit=0

Follows the same response pattern as /sequences/search and /programs/search for consistency.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add pagination to /stats/submitters endpoint</issue_title>
<issue_description>Add pagination support (limit + skip) for the /stats/submitters endpoint.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits November 4, 2025 20:01
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
…ation

Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Copilot AI changed the title [WIP] Add pagination support to /stats/submitters endpoint Add pagination support to /stats/submitters endpoint Nov 4, 2025
Copilot AI requested a review from ckrause November 4, 2025 20:15
@ckrause
Copy link
Contributor

ckrause commented Nov 13, 2025

@copilot Change the return type by wrapping the submitters list into an object that contains the total count. It should be analogous to programs and sequences.

Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot Change the return type by wrapping the submitters list into an object that contains the total count. It should be analogous to programs and sequences.

Done in commit 54c5d4f. The endpoint now returns {"total": <count>, "results": [<submitters>]} matching the pattern used by programs and sequences search endpoints.

@ckrause
Copy link
Contributor

ckrause commented Nov 13, 2025

@copilot Move the /stats/submitters endpoint to /submitters. Add a "Submissions" tag to the spec and use it for this endpoint instead of Stats.

Co-authored-by: ckrause <840744+ckrause@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot Move the /stats/submitters endpoint to /submitters. Add a "Submissions" tag to the spec and use it for this endpoint instead of Stats.

Done in commit d701b4c. The endpoint has been moved from /v2/stats/submitters to /v2/submitters and now uses the "Submissions" tag instead of "Stats".

Copilot AI changed the title Add pagination support to /stats/submitters endpoint Add pagination support to /submitters endpoint Nov 13, 2025
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.

Add pagination to /stats/submitters endpoint

2 participants