feat(websites): add sorting and results-per-page controls to website list#4118
feat(websites): add sorting and results-per-page controls to website list#4118Yashh56 wants to merge 13 commits intoumami-software:devfrom
Conversation
|
@Yashh56 is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR adds sorting (by visitors, pageviews, name, domain) and results-per-page controls to the website list, backed by new Prisma query logic and three new SQL helpers. Of the six concerns raised in previous threads, five are now addressed: Confidence Score: 4/5Safe to merge for PostgreSQL deployments; ClickHouse+pageviews sort still falls back to a full in-memory load of all matching websites. Five of six prior P1 concerns are resolved, showing strong convergence. The remaining issue — in-memory pagination for ClickHouse pageviews sort via getWebsitesByActivityFallback — is a production reliability risk on ClickHouse deployments with large website counts and keeps the score at 4 rather than 5. src/queries/prisma/website.ts — specifically getWebsitesByActivityFallback and its interaction with getActivityOrderQuery returning null for ClickHouse+pageviews. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as WebsitesDataTable
participant API as /me/websites (GET)
participant GW as getWebsites()
participant ACT as fetchActivitySortedWebsitePage()
participant FB as getWebsitesByActivityFallback()
participant DEC as decorateWebsiteList()
participant SQL as SQL helpers
UI->>API: orderBy, sortDescending, pageSize, timezone, includeMetrics
API->>GW: filters (parsed + validated)
alt orderBy is visitors or pageviews
GW->>ACT: criteria, filters
alt PostgreSQL (or ClickHouse + visitors)
ACT->>SQL: rawQuery — COUNT + activity LEFT JOIN, LIMIT/OFFSET
ACT-->>GW: {ids[], count, page, pageSize}
GW->>SQL: findMany WHERE id IN (ids[])
else ClickHouse + pageviews
ACT-->>GW: null
GW->>FB: criteria, filters
FB->>SQL: findMany (ALL websites, no pagination)
FB->>SQL: getWebsiteListStats (sort key)
FB-->>GW: sorted + sliced page
end
alt includeMetrics = true
GW->>DEC: attachMetricsToWebsites
DEC->>SQL: getWebsiteListStats (today)
DEC->>SQL: getWebsiteListStats (yesterday)
DEC->>SQL: getWebsiteListActivity (7 days)
DEC->>SQL: getWebsiteListActiveVisitors (last 5 min)
end
else orderBy is name or domain (or absent)
GW->>SQL: pagedQuery (DB-level ORDER BY + LIMIT/OFFSET)
opt includeMetrics = true
GW->>DEC: attachMetricsToWebsites (4 parallel queries)
end
end
GW-->>API: {data[], count, page, pageSize, metrics?}
API-->>UI: JSON response
Reviews (7): Last reviewed commit: "fix(websites): validate website list sor..." | Re-trigger Greptile |
|
@Yashh56 That looks like a really cool feature! Well done and thanks for all your hard work! 💪🤩 Just out of curiosity, could you please add a demo video or some screenshots? I’d love to see what the end result looks like 👀 |
|
Hi @franciscao633 and @mikecao, could you please take a look and share your feedback? |
…rting-pagination
|
This PR looks really nice. I’ve noticed that many PRs just sit around without getting reviewed these days. I submitted a translation PR two months ago, and it’s still waiting for a review with no one taking a look at it. |

This pull request introduces sorting and paging enhancements to the websites data table, enabling users to sort websites by visitors, pageviews, name, or domain, and to select the number of results per page. It also updates the backend API and query logic to support these new features, including activity-based sorting (by visitors or pageviews) that uses recent statistics. Additionally, internationalization labels and schema definitions have been updated to accommodate these UI changes.
Frontend: Table Sorting & Paging UI
WebsitesDataTable, allowing users to sort by visitors, pageviews, name, or domain, and to choose how many results are displayed per page. These selections update the URL parameters and trigger new queries. (src/app/(main)/websites/WebsitesDataTable.tsx, [1] [2] [3] [4]Backend: API & Schema Updates
orderBy,sortDescending) and paging, and to handle timezone-aware queries. The schema was updated to parse and validate these parameters. (src/app/api/websites/route.ts,src/app/api/me/websites/route.ts,src/app/api/users/[userId]/websites/route.ts,src/app/api/teams/[teamId]/websites/route.ts, src/lib/schema.tsR84-R87)Backend: Activity-based Sorting Logic
src/queries/prisma/website.ts, [1] [2] [3] [4]Backend: Website List Stats Query
getWebsiteListStats) to efficiently aggregate pageview and visitor counts per website for a given date range, supporting both relational and ClickHouse backends. (src/queries/sql/getWebsiteListStats.ts, [1] [2]Internationalization
public/intl/messages/en-US.json,src/components/messages.ts, [1] [2] [3] [4]Close : #4102