mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-10 14:41:49 +02:00
uncommit
This commit is contained in:
parent
8ca4b2acf8
commit
211e261c71
28 changed files with 519 additions and 324 deletions
|
@ -1,4 +1,7 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import { shortUrl } from "@/utils/absolute-url";
|
||||
|
||||
import { possiblyPublicProcedure, router } from "../trpc";
|
||||
|
||||
|
@ -14,4 +17,48 @@ export const dashboard = router({
|
|||
|
||||
return { activePollCount };
|
||||
}),
|
||||
getPending: possiblyPublicProcedure.query(async ({ ctx }) => {
|
||||
const polls = await prisma.poll.findMany({
|
||||
where: {
|
||||
userId: ctx.user.id,
|
||||
status: "live",
|
||||
deleted: false,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
createdAt: true,
|
||||
status: true,
|
||||
options: {
|
||||
select: {
|
||||
startTime: true,
|
||||
duration: true,
|
||||
},
|
||||
},
|
||||
_count: {
|
||||
select: {
|
||||
participants: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
take: 3,
|
||||
});
|
||||
|
||||
return polls.map((poll) => {
|
||||
return {
|
||||
id: poll.id,
|
||||
title: poll.title,
|
||||
createdAt: poll.createdAt,
|
||||
range: {
|
||||
start: poll.options[0].startTime,
|
||||
end: dayjs(poll.options[poll.options.length - 1].startTime)
|
||||
.add(poll.options[poll.options.length - 1].duration, "minute")
|
||||
.toDate(),
|
||||
},
|
||||
status: poll.status,
|
||||
responseCount: poll._count.participants,
|
||||
inviteLink: shortUrl(`/invite/${poll.id}`),
|
||||
};
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue