mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 14:44:15 +00:00
feat: astro test
This commit is contained in:
parent
df6e31ba89
commit
84144c383c
262 changed files with 18993 additions and 2655 deletions
20
backend/src/app/random/page.tsx
Normal file
20
backend/src/app/random/page.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { redirect } from "next/navigation";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function RandomPage() {
|
||||
const count = await prisma.mii.count();
|
||||
if (count === 0) redirect("/");
|
||||
|
||||
const randomIndex = Math.floor(Math.random() * count);
|
||||
const randomMii = await prisma.mii.findFirst({
|
||||
where: { in_queue: false, quarantined: false },
|
||||
skip: randomIndex,
|
||||
take: 1,
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!randomMii) redirect(process.env.NEXT_PUBLIC_FRONTEND_URL || "http://localhost:4321");
|
||||
redirect(`${process.env.NEXT_PUBLIC_FRONTEND_URL}/mii/${randomMii.id}`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue