Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

⚡️ Optimize options query

Luke Vellabc521f7ecb54
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",
},