From bc521f7ecb54ea8e0f99591610efb855deeb3a5f Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Fri, 25 Aug 2023 18:31:09 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Optimize=20options=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/utils/date-time-utils.ts | 4 +++- apps/web/src/utils/trpc/types.ts | 4 ++-- packages/backend/trpc/routers/polls.ts | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/web/src/utils/date-time-utils.ts b/apps/web/src/utils/date-time-utils.ts index 0c8821030..daf0784d7 100644 --- a/apps/web/src/utils/date-time-utils.ts +++ b/apps/web/src/utils/date-time-utils.ts @@ -1,4 +1,4 @@ -import { Option, TimeFormat } from "@rallly/database"; +import { TimeFormat } from "@rallly/database"; import dayjs from "dayjs"; import { @@ -6,6 +6,8 @@ import { TimeOption, } from "../components/forms/poll-options-form"; +type Option = { id: string; start: Date; duration: number }; + export const getBrowserTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone; diff --git a/apps/web/src/utils/trpc/types.ts b/apps/web/src/utils/trpc/types.ts index 151351739..15365ad34 100644 --- a/apps/web/src/utils/trpc/types.ts +++ b/apps/web/src/utils/trpc/types.ts @@ -1,11 +1,11 @@ -import { Option, User } from "@rallly/database"; +import { User } from "@rallly/database"; export type GetPollApiResponse = { id: string; title: string; location: string | null; description: string | null; - options: Option[]; + options: { id: string; start: Date; duration: number }[]; user: User | null; timeZone: string | null; adminUrlId: string; diff --git a/packages/backend/trpc/routers/polls.ts b/packages/backend/trpc/routers/polls.ts index f8fa5c6f7..abbbe9b7c 100644 --- a/packages/backend/trpc/routers/polls.ts +++ b/packages/backend/trpc/routers/polls.ts @@ -405,6 +405,11 @@ export const polls = router({ hideScores: true, demo: true, options: { + select: { + id: true, + start: true, + duration: true, + }, orderBy: { start: "asc", },