fixup: throw elephant out the room
Build and Push Image / docker (push) Successful in 2m54s

This commit is contained in:
2026-05-22 23:06:41 +07:00 Unverified
parent 4c24487856
commit 540c38167f
3 changed files with 23 additions and 36 deletions
+14 -23
View File
@@ -29,13 +29,9 @@ import { db } from "@/lib/db";
import { endgameSubmissions } from "@/lib/db/schema";
import { getEndgameConfig, random, wipe } from "../api";
import { LimitManager, SlipButton, SubmissionList, Watcher } from "./client";
import { desc } from "drizzle-orm";
import { desc, sql } from "drizzle-orm";
export default async function AdminLayout({
children,
}: {
children: React.ReactNode;
}) {
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
if (!(await adminCheck())) redirect("/login");
const subs = await db
.select({
@@ -43,7 +39,14 @@ export default async function AdminLayout({
name: endgameSubmissions.name,
checked: endgameSubmissions.checked,
queue: endgameSubmissions.queue,
publicQueue: endgameSubmissions.publicQueue,
publicQueue: sql<number>`
${endgameSubmissions.queue} - (
select count(*)
from ${endgameSubmissions} e2
where e2.checked = true
and e2.queue < ${endgameSubmissions.queue}
)
`,
paid: endgameSubmissions.paid,
archived: endgameSubmissions.archived,
})
@@ -57,12 +60,7 @@ export default async function AdminLayout({
<div className="flex justify-between items-center">
<b>Admin</b>
<div className="flex gap-1">
<Button
variant="ghost"
size="icon"
className="size-8"
onClick={random}
>
<Button variant="ghost" size="icon" className="size-8" onClick={random}>
<Dice5 size={24} className="size-6" />
</Button>
<SlipButton />
@@ -74,18 +72,14 @@ export default async function AdminLayout({
</AlertDialogTrigger>
<AlertDialogContent className="z-101">
<AlertDialogHeader>
<AlertDialogTitle>
คุณมั่นใจที่จะล้างข้อมูลทั้งหมดใช่ไหม?
</AlertDialogTitle>
<AlertDialogTitle>คุณมั่นใจที่จะล้างข้อมูลทั้งหมดใช่ไหม?</AlertDialogTitle>
<AlertDialogDescription>
การกระทำนี้ไม่สามารถย้อนกลับได้ เราจะลบบัญชีของท่านออกจากระบบ
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>ยกเลิก</AlertDialogCancel>
<AlertDialogAction onClick={wipe}>
ดำเนินการต่อ
</AlertDialogAction>
<AlertDialogAction onClick={wipe}>ดำเนินการต่อ</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
@@ -103,10 +97,7 @@ export default async function AdminLayout({
<SidebarFooter>
<SidebarGroup>
<SidebarGroupLabel>การตั้งค่า</SidebarGroupLabel>
<LimitManager
config={config}
length={subs.reduce((c, s) => c + (s.paid ? 1 : 0), 0)}
/>
<LimitManager config={config} length={subs.reduce((c, s) => c + (s.paid ? 1 : 0), 0)} />
</SidebarGroup>
</SidebarFooter>
</Sidebar>
+9 -2
View File
@@ -1,4 +1,4 @@
import { and, eq, gt, lt, not, or } from "drizzle-orm";
import { and, eq, gt, lt, not, or, sql } from "drizzle-orm";
import { AlertCircle, BookAlert, CircleDollarSign, SendHorizonal, X } from "lucide-react";
import type { Metadata } from "next";
import { cookies } from "next/headers";
@@ -66,7 +66,14 @@ export default async function EndgamePage() {
.select({
// Using endgame.submissions.queue here because
// ${endgameSubmissions.queue} does not work
queue: endgameSubmissions.publicQueue,
queue: sql<number>`
${endgameSubmissions.queue} - (
select count(*)
from ${endgameSubmissions} e2
where e2.checked = true
and e2.queue < ${endgameSubmissions.queue}
)
`,
paid: endgameSubmissions.paid,
price: endgameSubmissions.price,
expires: endgameSubmissions.expires,
-11
View File
@@ -134,17 +134,6 @@ export const endgameSubmissions = endgame.table("submissions", {
}),
expires: timestamp().$defaultFn(() => new Date(Date.now() + 20 * 60 * 1000)), // 20 minutes to pay
queue: serial(),
publicQueue: integer()
.notNull()
.generatedAlwaysAs(
(): SQL => sql`
${endgameSubmissions.queue} - (
select count(*)
from ${endgameSubmissions} as e2
where e2.checked = true
and e2.queue < endgame.submissions.queue
)`,
),
server: endgameServer().notNull(),
service: text()
.references(() => endgameTypes.id)