mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +02:00
♻️ Remove legacy start column (#1113)
This commit is contained in:
parent
14d0889a37
commit
533e347557
7 changed files with 16 additions and 128 deletions
|
@ -30,7 +30,7 @@ function FinalTime({ start, duration }: { start: Date; duration: number }) {
|
|||
return <Trans i18nKey="allDay" />;
|
||||
}
|
||||
return (
|
||||
<span>{`${adjustTimeZone(start, !poll.timeZone).format("LT")} - ${adjustTimeZone(dayjs(start).add(duration, "minutes"), !poll.timeZone).format("LT")}`}</span>
|
||||
<span>{`${adjustTimeZone(start, !poll.timeZone).format("LT")} - ${adjustTimeZone(dayjs(start).add(duration, "minutes"), !poll.timeZone).format(poll.timeZone ? "LT z" : "LT")}`}</span>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,6 @@ export type OptionScore = {
|
|||
no: string[];
|
||||
};
|
||||
|
||||
export const useCurrentPollOptions = () => {
|
||||
const pollId = useCurrentEventId();
|
||||
return trpc.polls.options.list.useQuery({ pollId });
|
||||
};
|
||||
|
||||
export const useCreatePollLink = () => {
|
||||
const pollId = useCurrentEventId();
|
||||
const basePath = `/poll/${pollId}`;
|
||||
|
|
|
@ -5,7 +5,7 @@ export type GetPollApiResponse = {
|
|||
title: string;
|
||||
location: string | null;
|
||||
description: string | null;
|
||||
options: { id: string; start: Date; startTime: Date; duration: number }[];
|
||||
options: { id: string; startTime: Date; duration: number }[];
|
||||
user: User | null;
|
||||
timeZone: string | null;
|
||||
adminUrlId: string;
|
||||
|
|
|
@ -17,7 +17,6 @@ import {
|
|||
router,
|
||||
} from "../trpc";
|
||||
import { comments } from "./polls/comments";
|
||||
import { options } from "./polls/options";
|
||||
import { participants } from "./polls/participants";
|
||||
|
||||
dayjs.extend(toArray);
|
||||
|
@ -44,7 +43,6 @@ const getPollIdFromAdminUrlId = async (urlId: string) => {
|
|||
export const polls = router({
|
||||
participants,
|
||||
comments,
|
||||
options,
|
||||
// START LEGACY ROUTES
|
||||
create: possiblyPublicProcedure
|
||||
.input(
|
||||
|
@ -101,7 +99,6 @@ export const polls = router({
|
|||
options: {
|
||||
createMany: {
|
||||
data: input.options.map((option) => ({
|
||||
start: dayjs(option.startDate).utc(true).toDate(),
|
||||
startTime: input.timeZone
|
||||
? dayjs(option.startDate).tz(input.timeZone, true).toDate()
|
||||
: dayjs(option.startDate).utc(true).toDate(),
|
||||
|
@ -375,12 +372,11 @@ export const polls = router({
|
|||
options: {
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
startTime: true,
|
||||
duration: true,
|
||||
},
|
||||
orderBy: {
|
||||
start: "asc",
|
||||
startTime: "asc",
|
||||
},
|
||||
},
|
||||
user: true,
|
||||
|
@ -514,13 +510,6 @@ export const polls = router({
|
|||
duration: true,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
},
|
||||
closed: true,
|
||||
participants: {
|
||||
select: {
|
||||
|
@ -597,13 +586,6 @@ export const polls = router({
|
|||
duration: true,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
},
|
||||
closed: true,
|
||||
participants: {
|
||||
select: {
|
||||
|
@ -631,58 +613,6 @@ export const polls = router({
|
|||
|
||||
return { total, rows };
|
||||
}),
|
||||
list: possiblyPublicProcedure.query(async ({ ctx }) => {
|
||||
const polls = await prisma.poll.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
deleted: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
location: true,
|
||||
createdAt: true,
|
||||
timeZone: true,
|
||||
adminUrlId: true,
|
||||
participantUrlId: true,
|
||||
status: true,
|
||||
event: {
|
||||
select: {
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
},
|
||||
options: {
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
},
|
||||
closed: true,
|
||||
participants: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
createdAt: "desc",
|
||||
},
|
||||
{ name: "desc" },
|
||||
],
|
||||
},
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
createdAt: "desc",
|
||||
},
|
||||
{ title: "asc" },
|
||||
],
|
||||
});
|
||||
|
||||
return polls;
|
||||
}),
|
||||
book: proProcedure
|
||||
.input(
|
||||
z.object({
|
||||
|
@ -743,7 +673,7 @@ export const polls = router({
|
|||
id: input.optionId,
|
||||
},
|
||||
select: {
|
||||
start: true,
|
||||
startTime: true,
|
||||
duration: true,
|
||||
},
|
||||
});
|
||||
|
@ -755,10 +685,12 @@ export const polls = router({
|
|||
});
|
||||
}
|
||||
|
||||
let eventStart = dayjs(option.start).utc();
|
||||
let eventStart = dayjs(option.startTime);
|
||||
|
||||
if (poll.timeZone) {
|
||||
eventStart = eventStart.tz(poll.timeZone, true);
|
||||
eventStart = eventStart.tz(poll.timeZone);
|
||||
} else {
|
||||
eventStart = eventStart.utc();
|
||||
}
|
||||
|
||||
await prisma.poll.update({
|
||||
|
@ -992,7 +924,6 @@ export const polls = router({
|
|||
disableComments: true,
|
||||
options: {
|
||||
select: {
|
||||
start: true,
|
||||
startTime: true,
|
||||
duration: true,
|
||||
},
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import { z } from "zod";
|
||||
|
||||
import { publicProcedure, router } from "../../trpc";
|
||||
|
||||
export const options = router({
|
||||
list: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
pollId: z.string(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ input: { pollId } }) => {
|
||||
const options = await prisma.option.findMany({
|
||||
where: {
|
||||
pollId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
start: true,
|
||||
duration: true,
|
||||
},
|
||||
orderBy: [
|
||||
{
|
||||
start: "asc",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return options;
|
||||
}),
|
||||
delete: publicProcedure
|
||||
.input(
|
||||
z.object({
|
||||
optionId: z.string(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input: { optionId } }) => {
|
||||
await prisma.option.delete({
|
||||
where: {
|
||||
id: optionId,
|
||||
},
|
||||
});
|
||||
}),
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `start` on the `options` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "options" DROP COLUMN "start";
|
|
@ -195,7 +195,6 @@ model Participant {
|
|||
|
||||
model Option {
|
||||
id String @id @default(cuid())
|
||||
start DateTime @db.Timestamp(0) // @deprecated - use startTime
|
||||
startTime DateTime @db.Timestamp(0) @map("start_time")
|
||||
duration Int @default(0) @map("duration_minutes")
|
||||
pollId String @map("poll_id")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue