️ Optimize options query

This commit is contained in:
Luke Vella 2023-08-25 18:31:09 +01:00
parent f10fd919c7
commit bc521f7ecb
3 changed files with 10 additions and 3 deletions

View file

@ -1,4 +1,4 @@
import { Option, TimeFormat } from "@rallly/database"; import { TimeFormat } from "@rallly/database";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { import {
@ -6,6 +6,8 @@ import {
TimeOption, TimeOption,
} from "../components/forms/poll-options-form"; } from "../components/forms/poll-options-form";
type Option = { id: string; start: Date; duration: number };
export const getBrowserTimeZone = () => export const getBrowserTimeZone = () =>
Intl.DateTimeFormat().resolvedOptions().timeZone; Intl.DateTimeFormat().resolvedOptions().timeZone;

View file

@ -1,11 +1,11 @@
import { Option, User } from "@rallly/database"; import { User } from "@rallly/database";
export type GetPollApiResponse = { export type GetPollApiResponse = {
id: string; id: string;
title: string; title: string;
location: string | null; location: string | null;
description: string | null; description: string | null;
options: Option[]; options: { id: string; start: Date; duration: number }[];
user: User | null; user: User | null;
timeZone: string | null; timeZone: string | null;
adminUrlId: string; adminUrlId: string;

View file

@ -405,6 +405,11 @@ export const polls = router({
hideScores: true, hideScores: true,
demo: true, demo: true,
options: { options: {
select: {
id: true,
start: true,
duration: true,
},
orderBy: { orderBy: {
start: "asc", start: "asc",
}, },