Skip to content

feat(events): return related.entry_counts on /events/entity#916

Merged
dylanjeffers merged 1 commit into
mainfrom
feat/events-entity-entry-counts
Jun 6, 2026
Merged

feat(events): return related.entry_counts on /events/entity#916
dylanjeffers merged 1 commit into
mainfrom
feat/events-entity-entry-counts

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

What

The /v1/events/entity endpoint returned only data. Every consumer that resolves a contest through it (useEventIdsByEntityIdgetEntityEvents) then had to fire a separate /tracks/{id}/remixes?only_contest_entries=true&limit=0 per contest just to render the entry-count badge.

This adds related.entry_counts to the response — keyed by the contest's parent track hashid — mirroring the existing /events/remix-contests discovery endpoint. The client can now prime useRemixesCount({ isContestEntry: true }) directly from the same call.

Why

The count-only request is an N+1 on web Explore's featured contests (one per card) and an extra round-trip on the track-page contest section and cold/deep-linked contest pages. The /events/entity call already batches all cards into one request, so threading entry counts through it collapses N count requests to zero.

Surface Count requests today After
Mobile Explore (useAllRemixContests) 0 (already primed) 0
Web Explore (useExploreContent → ContestCard) N (one per card) 0
Track-page contest section 1 per contest 0
Cold contest detail page 1 0

Details

  • Entry count uses the same in-window filter as v1EventsRemixContests: child track created after contest start, before end_date, and currently listed (is_current, not deleted, not unlisted).
  • Only remix_contest events on track entities get a count; each such event is defaulted to 0 so empty contests prime a definitive "no entries" and still skip the count request.
  • Swagger: events_response now references the existing remix_contests_related schema (reused for entry_counts), so SDK regen picks up related on getEntityEvents.

Test

TestGetEntityEventsEntryCounts seeds a contest with 2 in-window remixes + 1 pre-window remix and asserts related.entry_counts counts only the 2 in-window entries. Full api package suite passes.

🤖 Generated with Claude Code

The /v1/events/entity endpoint returned only `data`, so every consumer that
resolves a contest through it had to fire a separate
`/tracks/{id}/remixes?only_contest_entries=true&limit=0` just to render the
entry-count badge. This is an N+1 on web Explore's featured contests (one
count request per card) and an extra round-trip on the track-page contest
section and cold/deep-linked contest pages.

Compute per-contest entry counts alongside the events query and return them
under `related.entry_counts`, keyed by the contest's parent track hashid —
mirroring the existing /events/remix-contests discovery endpoint so the client
can prime `useRemixesCount({ isContestEntry: true })` directly. The count uses
the same in-window filter (child track created after contest start, before
end_date, currently listed) and only applies to remix_contest events on track
entities.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dylanjeffers dylanjeffers merged commit b968ac5 into main Jun 6, 2026
5 checks passed
@dylanjeffers dylanjeffers deleted the feat/events-entity-entry-counts branch June 6, 2026 06:17
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