Skip to content

Sort and limit application analytics partner table#4138

Open
devkiran wants to merge 1 commit into
mainfrom
applications-analytics-sort-limit
Open

Sort and limit application analytics partner table#4138
devkiran wants to merge 1 commit into
mainfrom
applications-analytics-sort-limit

Conversation

@devkiran

@devkiran devkiran commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator
  • Sort partner rows by the selected application event stage (visits, starts, submissions, approvals) via a new optional event query param
  • Limit results to the top 100 partners
  • Paginate the table client-side (10 per page) instead of rendering all rows
  • Preserve DB sort order in the API response mapping

Summary by CodeRabbit

  • New Features

    • Partner analytics can now be filtered by a specific application stage, showing results for the selected event.
    • Partner tables now use stage-aware sorting to better match the chosen analytics view.
  • Bug Fixes

    • Improved pagination in the partner analytics table so only the current page is rendered while totals remain accurate.
    • Analytics queries now avoid carrying the event filter in the URL when it shouldn’t be persisted.

- Sort partner rows by the selected application event stage (visits,
  starts, submissions, approvals) via a new optional `event` query param
- Limit results to the top 100 partners
- Paginate the table client-side (10 per page) instead of rendering all rows
- Preserve DB sort order in the API response mapping
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Jul 7, 2026 3:38pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 636b0b22-d096-4015-b9fb-38fe97932de4

📥 Commits

Reviewing files that changed from the base of the PR and between bbf1131 and 31afea8.

📒 Files selected for processing (5)
  • apps/web/app/(ee)/api/partners/applications/analytics/route.ts
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/applications/applications-partners-table.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/applications/use-applications-analytics-filters.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/applications/use-applications-analytics.ts
  • apps/web/lib/application-events/schema.ts

📝 Walkthrough

Walkthrough

Adds an optional event (stage) filter to the partner application analytics query schema and API route, using it to select a sort column via a new stage-to-count mapping and refactoring result assembly. Frontend hooks pass the stage parameter, exclude it from query strings, and the partners table applies client-side pagination and stage-based sorting.

Changes

Stage-based partner analytics sorting

Layer / File(s) Summary
Schema and API sorting logic
apps/web/lib/application-events/schema.ts, apps/web/app/(ee)/api/partners/applications/analytics/route.ts
Adds an optional event enum field to applicationEventAnalyticsQuerySchema, parses it in the GET handler, and uses a new STAGE_SORT_COLUMN mapping in byPartnerId to sort partner aggregation by the chosen stage's count; refactors result assembly to use a partnersById lookup instead of the prior map/iterate approach.
Frontend query wiring and table pagination
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/applications/use-applications-analytics.ts, .../use-applications-analytics-filters.tsx, .../applications-partners-table.tsx
Passes event: stage into partner analytics queries, excludes "event" from generated query strings, and updates ApplicationsPartnersTable to read stage from useApplicationsAnalyticsQuery, apply client-side pagination via a memoized slice, and sort by stage in useTable.

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

Sequence Diagram(s)

sequenceDiagram
  participant Table as ApplicationsPartnersTable
  participant Route as Analytics API Route
  participant DB as Prisma/Database

  Table->>Route: GET analytics request (event=stage)
  Route->>Route: parse event, resolve sortColumn via STAGE_SORT_COLUMN
  Route->>DB: groupBy referredByPartnerId orderBy sortColumn._count
  DB-->>Route: aggregated event rows
  Route->>Route: build partnersById lookup, resolve partner per row
  Route-->>Table: formatted partner analytics results
  Table->>Table: slice results for current page, render sorted by stage
Loading

Suggested reviewers: steven-tey

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: sorting and limiting the application analytics partner table.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch applications-analytics-sort-limit

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

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