feat: Troubleshooter atom (#27497)
This commit is contained in:
1 parent
a71d62dc33
commit
8a17ebc2ef
31 files changed
+821
-305
No files matched your search
@@ -6,7 +6,7 @@ import type { TGetInputSchema } from "./get.schema";
|
||||
|
||||
type GetOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
user: Pick<NonNullable<TrpcSessionUser>, "id" | "timeZone" | "defaultScheduleId">;
|
||||
};
|
||||
input: TGetInputSchema;
|
||||
};
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import type { TGetByEventSlugInputSchema } from "./getScheduleByEventTypeSlug.sc
|
||||
|
||||
type GetOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
user: Pick<NonNullable<TrpcSessionUser>, "id" | "timeZone" | "defaultScheduleId">;
|
||||
prisma: PrismaClient;
|
||||
};
|
||||
input: TGetByEventSlugInputSchema;
|
||||
|
||||
@@ -5,18 +5,19 @@ import type { TrpcSessionUser } from "../../../types";
|
||||
|
||||
type ListWithTeamOptions = {
|
||||
ctx: {
|
||||
user: NonNullable<TrpcSessionUser>;
|
||||
user: Pick<NonNullable<TrpcSessionUser>, "id">;
|
||||
};
|
||||
};
|
||||
|
||||
export const listWithTeamHandler = async ({ ctx }: ListWithTeamOptions) => {
|
||||
const userId = ctx.user.id;
|
||||
const query = Prisma.sql`SELECT "public"."EventType"."id", "public"."EventType"."teamId", "public"."EventType"."title", "public"."EventType"."slug", "public"."EventType"."length", "j1"."name" as "teamName"
|
||||
const query = Prisma.sql`SELECT "public"."EventType"."id", "public"."EventType"."teamId", "public"."EventType"."title", "public"."EventType"."slug", "public"."EventType"."length", "j1"."name" as "teamName", "u"."username" as "username"
|
||||
FROM "public"."EventType"
|
||||
LEFT JOIN "public"."Team" AS "j1" ON ("j1"."id") = ("public"."EventType"."teamId")
|
||||
WHERE "public"."EventType"."userId" = ${userId}
|
||||
LEFT JOIN "public"."users" AS "u" ON ("u"."id") = ("public"."EventType"."userId")
|
||||
WHERE "public"."EventType"."userId" = ${userId} AND "public"."EventType"."teamId" IS NULL
|
||||
UNION
|
||||
SELECT "public"."EventType"."id", "public"."EventType"."teamId", "public"."EventType"."title", "public"."EventType"."slug", "public"."EventType"."length", "j1"."name" as "teamName"
|
||||
SELECT "public"."EventType"."id", "public"."EventType"."teamId", "public"."EventType"."title", "public"."EventType"."slug", "public"."EventType"."length", "j1"."name" as "teamName", NULL as "username"
|
||||
FROM "public"."EventType"
|
||||
INNER JOIN "public"."Team" AS "j1" ON ("j1"."id") = ("public"."EventType"."teamId")
|
||||
INNER JOIN "public"."Membership" AS "t2" ON "t2"."teamId" = "j1"."id"
|
||||
@@ -30,6 +31,7 @@ export const listWithTeamHandler = async ({ ctx }: ListWithTeamOptions) => {
|
||||
slug: string;
|
||||
length: number;
|
||||
teamName: string | null;
|
||||
username: string | null;
|
||||
}[]
|
||||
>(query);
|
||||
|
||||
@@ -39,5 +41,6 @@ export const listWithTeamHandler = async ({ ctx }: ListWithTeamOptions) => {
|
||||
title: row.title,
|
||||
slug: row.slug,
|
||||
length: row.length,
|
||||
username: row.teamId ? null : row.username,
|
||||
}));
|
||||
};
|
||||
Reference in new issue
Block a user