Skip to content

Add campaign accounts leaderboard endpoint#47

Merged
kasparkallas merged 2 commits intomainfrom
claude/add-campaign-accounts-endpoint-siYhG
Mar 3, 2026
Merged

Add campaign accounts leaderboard endpoint#47
kasparkallas merged 2 commits intomainfrom
claude/add-campaign-accounts-endpoint-siYhG

Conversation

@kasparkallas
Copy link
Collaborator

Summary

This PR adds a new /points/accounts endpoint that retrieves all accounts in a campaign with their point balances, event counts, and last event timestamps. This enables building leaderboard views with pagination and flexible sorting options.

Key Changes

  • New API endpoint (GET /points/accounts): Queries all accounts in a campaign with their point balances

    • Supports sorting by totalPoints, eventCount, or lastEventAt
    • Supports ascending/descending order
    • Includes pagination with configurable limit (1-100, default 50) and page number
    • Validates required campaignId parameter and returns appropriate error responses
    • Verifies campaign exists before querying accounts
  • Type definitions: Added CampaignAccountResponse and CampaignAccountsResponse types in domains/points/types.ts with Zod schemas for runtime validation

  • API schemas: Added CampaignAccountsQuerySchema and CampaignAccountSchema for OpenAPI documentation and request/response validation

  • OpenAPI registry: Registered new endpoint with comprehensive documentation including:

    • Query parameter descriptions
    • Response examples showing account data and pagination metadata
    • Error responses (400, 404, 500)
    • Updated authentication documentation to include /accounts as a public endpoint

Implementation Details

  • The endpoint queries the point-balances collection filtered by campaign ID
  • Results are sorted using Payload's sort syntax (prefix with - for descending)
  • Pagination metadata is included in responses (page, limit, totalDocs, totalPages, hasNextPage, hasPrevPage)
  • Comprehensive input validation with specific error messages for invalid parameters
  • Error handling with appropriate HTTP status codes and logging

https://claude.ai/code/session_01EJiKHPRqX1KE7L7y7r1DQR

claude added 2 commits March 3, 2026 01:14
Add a new public endpoint to query all accounts in a campaign with their
point balances, event counts, and last event timestamps. Supports sorting
by totalPoints, eventCount, or lastEventAt with configurable sort order
and pagination — designed for building leaderboard views.

https://claude.ai/code/session_01EJiKHPRqX1KE7L7y7r1DQR
Include the new /accounts endpoint in the Authentication section's
public query endpoints list and add a leaderboard usage example to the
Getting Points migration guide section.

https://claude.ai/code/session_01EJiKHPRqX1KE7L7y7r1DQR
@vercel
Copy link

vercel bot commented Mar 3, 2026

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

Project Deployment Actions Updated (UTC)
superfluid-cms Ready Ready Preview, Comment Mar 3, 2026 11:27am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
superfluid-data Skipped Skipped Mar 3, 2026 11:27am

Request Review

@kasparkallas kasparkallas merged commit 9e0f646 into main Mar 3, 2026
4 checks passed
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.

2 participants