Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

toLocaleString pagination + add indexes

Steven Tey421151be69ac
diff --git a/apps/web/app/api/customers/route.ts b/apps/web/app/api/customers/route.ts
index 9cb9269c75..001e6b5791 100644
--- a/apps/web/app/api/customers/route.ts
+++ b/apps/web/app/api/customers/route.ts
@@ -79,10 +79,10 @@ export const GET = withWorkspace(
...(country && {
country,
}),
+ ...(linkId && {
+ linkId,
+ }),
}),
- ...(linkId && {
- linkId,
- }),
},
orderBy: {
[sortBy]: sortOrder,
diff --git a/packages/prisma/schema/customer.prisma b/packages/prisma/schema/customer.prisma
index 42d9b01d76..434163e73c 100644
--- a/packages/prisma/schema/customer.prisma
+++ b/packages/prisma/schema/customer.prisma
@@ -25,7 +25,10 @@ model Customer {
@@unique([projectId, externalId])
@@unique([projectConnectId, externalId])
+ @@index([projectId, createdAt])
+ @@index([projectId, saleAmount])
@@index([projectId, email, externalId, name])
@@index(externalId)
@@index(linkId)
+ @@index(country)
}
diff --git a/packages/ui/src/pagination-controls.tsx b/packages/ui/src/pagination-controls.tsx
index d243883797..a54fd57d7c 100644
--- a/packages/ui/src/pagination-controls.tsx
+++ b/packages/ui/src/pagination-controls.tsx
@@ -1,4 +1,4 @@
-import { cn, nFormatter } from "@dub/utils";
+import { cn } from "@dub/utils";
import { PaginationState } from "@tanstack/react-table";
import { PropsWithChildren } from "react";
@@ -37,20 +37,22 @@ export function PaginationControls({
{totalCount > 0 && (
<>
<span className="font-medium">
- {(pagination.pageIndex - 1) * pagination.pageSize + 1}-
+ {(
+ (pagination.pageIndex - 1) * pagination.pageSize +
+ 1
+ ).toLocaleString()}
+ -
{Math.min(
(pagination.pageIndex - 1) * pagination.pageSize +
pagination.pageSize,
totalCount,
- )}
+ ).toLocaleString()}
</span>{" "}
{showTotalCount && "of "}
</>
)}
{showTotalCount && (
- <span className="font-medium">
- {nFormatter(totalCount, { full: true })}
- </span>
+ <span className="font-medium">{totalCount.toLocaleString()}</span>
)}{" "}
{typeof unit === "function" ? unit(totalCount !== 1) : unit}
</div>
diff --git a/packages/ui/src/table/table.tsx b/packages/ui/src/table/table.tsx
index cb45d23999..807df7ea4c 100644
--- a/packages/ui/src/table/table.tsx
+++ b/packages/ui/src/table/table.tsx
@@ -521,12 +521,16 @@ export function Table<T>({
<div>
<span className="hidden sm:inline-block">Viewing</span>{" "}
<span className="font-medium">
- {(pagination.pageIndex - 1) * pagination.pageSize + 1}-
+ {(
+ (pagination.pageIndex - 1) * pagination.pageSize +
+ 1
+ ).toLocaleString()}
+ -
{Math.min(
(pagination.pageIndex - 1) * pagination.pageSize +
pagination.pageSize,
table.getRowCount(),
- )}
+ ).toLocaleString()}
</span>{" "}
of{" "}
<span className="font-medium">