-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Changing partner hover data #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f20340
c2fa79e
fb58a60
0e321ad
5e50c59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { AnalyticsResponse } from "@/lib/analytics/types"; | ||
| import { editQueryString } from "@/lib/analytics/utils"; | ||
| import useGroups from "@/lib/swr/use-groups"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused import&3a; View Details📝 Patch Detailsdiff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
index c7ee1f128..47b6d3f11 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
@@ -1,6 +1,5 @@
import { AnalyticsResponse } from "@/lib/analytics/types";
import { editQueryString } from "@/lib/analytics/utils";
-import useGroups from "@/lib/swr/use-groups";
import { AnalyticsContext } from "@/ui/analytics/analytics-provider";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
@@ -18,7 +17,6 @@ import useSWR from "swr";
export function AnalyticsPartnersTable() {
const { selectedTab, queryString } = useContext(AnalyticsContext);
- const { groups } = useGroups();
const { pagination, setPagination } = usePagination(10);
AnalysisUnused import&3a; useGroups in analytics partners table componentWhat fails&3a; TypeScript compiler reports How to reproduce&3a; cd apps/web && pnpm exec tsc --noEmit --noUnusedLocals --noUnusedParameters "app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx"Result&3a; TypeScript error about unused Expected&3a; No unused import warnings - the component explicitly passes |
||
| import { AnalyticsContext } from "@/ui/analytics/analytics-provider"; | ||
| import { PartnerRowItem } from "@/ui/partners/partner-row-item"; | ||
| import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row"; | ||
|
|
@@ -17,6 +18,7 @@ import useSWR from "swr"; | |
|
|
||
| export function AnalyticsPartnersTable() { | ||
| const { selectedTab, queryString } = useContext(AnalyticsContext); | ||
| const { groups } = useGroups(); | ||
|
|
||
| const { pagination, setPagination } = usePagination(10); | ||
|
|
||
|
|
@@ -52,14 +54,15 @@ export function AnalyticsPartnersTable() { | |
| minSize: 250, | ||
| cell: ({ row }) => { | ||
| const p = row.original.partner; | ||
| // Note: groupId not available in analytics data, so no group rewards will be shown | ||
| return ( | ||
| <PartnerRowItem | ||
| partner={{ | ||
| ...p, | ||
| payoutsEnabledAt: p.payoutsEnabledAt | ||
| ? new Date(p.payoutsEnabledAt) | ||
| : null, | ||
| id: p.id, | ||
| name: p.name, | ||
| image: p.image, | ||
| }} | ||
| group={null} | ||
| /> | ||
| ); | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API route introduces a severe N+1 query performance issue by making individual database queries for each group to fetch reward&2f;discount data that may already be available from the original query.
View Details
📝 Patch Details
Analysis
N+1 query performance issue in GET &2f;api&2f;groups route
What fails&3a; The
getGroups()API route executes N+1 database queries when fetching reward and discount data for groups, causing significant performance degradation as the number of groups scales.How to reproduce&3a;
Result&3a; Each group triggers a separate
prisma.partnerGroup.findUnique()query inPromise.all()loop &28;lines 31-51 in route.ts&29;. For N groups, this creates N+1 total queries instead of a single optimized query.Expected&3a; Single query with JOINs to fetch all group data including rewards and discounts in one database round-trip, eliminating the N+1 query anti-pattern.