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.

fix userid groupby

Steven Teyee52a27174e8
diff --git a/apps/web/app/api/links/count/route.ts b/apps/web/app/api/links/count/route.ts
index 0cbc9c4222..5a386699dd 100644
--- a/apps/web/app/api/links/count/route.ts
+++ b/apps/web/app/api/links/count/route.ts
@@ -8,7 +8,7 @@ import { NextResponse } from "next/server";
export const GET = withWorkspace(
async ({ headers, searchParams, workspace }) => {
const params = getLinksCountQuerySchema.parse(searchParams);
- const { userId, domain } = params;
+ const { domain } = params;
if (domain) {
await getDomainOrThrow({ domain, workspace: workspace });
@@ -17,7 +17,6 @@ export const GET = withWorkspace(
const count = await getLinksCount({
searchParams: params,
workspaceId: workspace.id,
- userId,
});
return NextResponse.json(count, {
diff --git a/apps/web/lib/api/links/get-links-count.ts b/apps/web/lib/api/links/get-links-count.ts
index c7c52f45e1..af5ad6c3f6 100644
--- a/apps/web/lib/api/links/get-links-count.ts
+++ b/apps/web/lib/api/links/get-links-count.ts
@@ -6,7 +6,6 @@ import { combineTagIds } from "./utils";
export async function getLinksCount({
searchParams,
workspaceId,
- userId,
}: {
searchParams: z.infer<typeof getLinksCountQuerySchema>;
workspaceId: string;
@@ -19,6 +18,7 @@ export async function getLinksCount({
tagId,
tagIds,
tagNames,
+ userId,
showArchived,
withTags,
} = searchParams;
@@ -28,7 +28,6 @@ export async function getLinksCount({
const linksWhere = {
projectId: workspaceId,
archived: showArchived ? undefined : false,
- ...(userId && { userId }),
...(search && {
OR: [
{
@@ -44,6 +43,7 @@ export async function getLinksCount({
groupBy !== "domain" && {
domain,
}),
+ // when filtering by user, only filter by user if the filter group is not "Users"
...(userId &&
groupBy !== "userId" && {
userId,
diff --git a/apps/web/ui/links/use-link-filters.tsx b/apps/web/ui/links/use-link-filters.tsx
index ab49fc922b..75e14ed862 100644
--- a/apps/web/ui/links/use-link-filters.tsx
+++ b/apps/web/ui/links/use-link-filters.tsx
@@ -79,9 +79,9 @@ export function useLinkFilters() {
icon: User,
label: "Creator",
options:
- users?.map(({ id, name, image, count }) => ({
+ users?.map(({ id, name, email, image, count }) => ({
value: id,
- label: name,
+ label: name || email,
icon: (
<Avatar
user={{