refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (5)
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
9aa4f331bf
commit
30b54e99e7
40 files changed
+1183
-784
No files matched your search
+10
-5
@@ -1,10 +1,11 @@
|
||||
import { count, eq } from "drizzle-orm";
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
|
||||
import { cached } from "@/lib/cache";
|
||||
import { db, User } from "@/lib/db";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
import { ClientView } from "./client-view";
|
||||
|
||||
@@ -22,11 +23,15 @@ export default async function ClientPage() {
|
||||
]);
|
||||
|
||||
const ip = (await headers()).get("x-real-client-ip") ?? "0.0.0.0";
|
||||
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
|
||||
const ticket = await issueSsoTicket(userId, hotelName, ip);
|
||||
|
||||
const onlineCount = await cached("online_count", 10_000, () =>
|
||||
prisma.user.count({ where: { online: "1" } }),
|
||||
).catch(() => 0);
|
||||
const onlineCount = await cached("online_count", 10_000, async () => {
|
||||
const [row] = await db
|
||||
.select({ total: count() })
|
||||
.from(User)
|
||||
.where(eq(User.online, "1"));
|
||||
return row?.total ?? 0;
|
||||
}).catch(() => 0);
|
||||
|
||||
return (
|
||||
<ClientView
|
||||
|
||||
Reference in new issue
Block a user