diff --git a/apps/web/src/app/[locale]/poll/[urlId]/admin-page.tsx b/apps/web/src/app/[locale]/poll/[urlId]/admin-page.tsx
index 84f341609..3966c5183 100644
--- a/apps/web/src/app/[locale]/poll/[urlId]/admin-page.tsx
+++ b/apps/web/src/app/[locale]/poll/[urlId]/admin-page.tsx
@@ -5,14 +5,12 @@ import { PollFooter } from "@/components/poll/poll-footer";
import { PollHeader } from "@/components/poll/poll-header";
import { ResponsiveResults } from "@/components/poll/responsive-results";
import { ScheduledEvent } from "@/components/poll/scheduled-event";
-import { useTouchBeacon } from "@/components/poll/use-touch-beacon";
import { VotingForm } from "@/components/poll/voting-form";
import { GuestPollAlert } from "./guest-poll-alert";
import { UnsubscribeAlert } from "./unsubscribe-alert";
export function AdminPage() {
- useTouchBeacon();
return (
diff --git a/apps/web/src/app/api/house-keeping/delete-inactive-polls/route.ts b/apps/web/src/app/api/house-keeping/delete-inactive-polls/route.ts
index 6fbdfe640..b3e172820 100644
--- a/apps/web/src/app/api/house-keeping/delete-inactive-polls/route.ts
+++ b/apps/web/src/app/api/house-keeping/delete-inactive-polls/route.ts
@@ -4,8 +4,8 @@ import { NextResponse } from "next/server";
import { checkApiAuthorization } from "@/utils/api-auth";
/**
- * Marks inactive polls as deleted. Polls are inactive if they have not been
- * touched in the last 30 days and all dates are in the past.
+ * Marks inactive polls as deleted. Polls are inactive if the last option is more than
+ * 30 days in the past.
* Only marks polls as deleted if they belong to users without an active subscription
* or if they don't have a user associated with them.
*/
@@ -16,14 +16,11 @@ export async function POST() {
// Mark inactive polls as deleted in a single query
const { count: markedDeleted } = await prisma.poll.updateMany({
where: {
- touchedAt: {
- lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000), // 30 days ago
- },
deleted: false,
options: {
none: {
startTime: {
- gt: new Date(),
+ lt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
},
},
},
diff --git a/apps/web/src/components/poll/use-touch-beacon.ts b/apps/web/src/components/poll/use-touch-beacon.ts
deleted file mode 100644
index 0085e183e..000000000
--- a/apps/web/src/components/poll/use-touch-beacon.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { useMount } from "react-use";
-
-import { usePoll } from "@/contexts/poll";
-import { trpc } from "@/trpc/client";
-
-/**
- * Touching a poll updates a column with the current date. This information is used to
- * find polls that haven't been accessed for some time so that they can be deleted by house keeping.
- */
-export const useTouchBeacon = () => {
- const poll = usePoll();
- const touchMutation = trpc.polls.touch.useMutation({
- meta: { doNotInvalidate: true },
- });
-
- useMount(() => {
- touchMutation.mutate({ pollId: poll.id });
- });
-};
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index 52d687bba..07cd93a6e 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -365,6 +365,9 @@ export const polls = router({
data: { deleted: true, deletedAt: new Date() },
});
}),
+ /**
+ * @deprecated
+ */
touch: publicProcedure
.input(
z.object({
diff --git a/packages/database/prisma/schema.prisma b/packages/database/prisma/schema.prisma
index 0748a764d..9e94eaf68 100644
--- a/packages/database/prisma/schema.prisma
+++ b/packages/database/prisma/schema.prisma
@@ -151,7 +151,7 @@ model Poll {
status PollStatus @default(live)
deleted Boolean @default(false)
deletedAt DateTime? @map("deleted_at")
- touchedAt DateTime @default(now()) @map("touched_at")
+ touchedAt DateTime @default(now()) @map("touched_at") // @deprecated
participantUrlId String @unique @map("participant_url_id")
adminUrlId String @unique @map("admin_url_id")
eventId String? @unique @map("event_id")