revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,61 +1,61 @@
|
||||
import { AlertTriangle, Database, HeartPulse, Server } from "lucide-react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { canAccess, getAdminContext, PERMS } from "@/lib/permissions";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { HealthCheckClient } from "./health-check-client";
|
||||
import { AlertTriangle, Database, HeartPulse, Server } from 'lucide-react'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { canAccess, getAdminContext, PERMS } from '@/lib/permissions'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { HealthCheckClient } from './health-check-client'
|
||||
|
||||
async function getDevOpsData() {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const dayAgo = now - 86400;
|
||||
const now = Math.floor(Date.now() / 1000)
|
||||
const dayAgo = now - 86400
|
||||
|
||||
// DB health — simple count query
|
||||
let dbStatus: "healthy" | "error" = "healthy";
|
||||
let dbLatency = 0;
|
||||
let dbStatus: 'healthy' | 'error' = 'healthy'
|
||||
let dbLatency = 0
|
||||
try {
|
||||
const start = Date.now();
|
||||
await prisma.user.count({ take: 1 });
|
||||
dbLatency = Date.now() - start;
|
||||
const start = Date.now()
|
||||
await prisma.user.count({ take: 1 })
|
||||
dbLatency = Date.now() - start
|
||||
} catch {
|
||||
dbStatus = "error";
|
||||
dbStatus = 'error'
|
||||
}
|
||||
|
||||
// Recent emulator errors
|
||||
const recentErrors = await prisma.emulatorErrors.findMany({
|
||||
orderBy: { id: "desc" },
|
||||
orderBy: { id: 'desc' },
|
||||
take: 20,
|
||||
});
|
||||
})
|
||||
|
||||
const errorsToday = await prisma.emulatorErrors.count({
|
||||
where: { timestamp: { gte: dayAgo } },
|
||||
});
|
||||
})
|
||||
|
||||
// Emulator settings (version info)
|
||||
const emuVersion = await prisma.emulatorSettings.findFirst({
|
||||
where: { key: "version" },
|
||||
});
|
||||
where: { key: 'version' },
|
||||
})
|
||||
|
||||
// Online user count as proxy for emulator health
|
||||
const onlineUsers = await prisma.user.count({ where: { online: "1" } });
|
||||
const onlineUsers = await prisma.user.count({ where: { online: '1' } })
|
||||
|
||||
return {
|
||||
dbStatus,
|
||||
dbLatency,
|
||||
recentErrors,
|
||||
errorsToday,
|
||||
emuVersion: emuVersion?.value ?? "Unknown",
|
||||
emuVersion: emuVersion?.value ?? 'Unknown',
|
||||
onlineUsers,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default async function DevOpsPage() {
|
||||
const { session, permissions } = await getAdminContext();
|
||||
const { session, permissions } = await getAdminContext()
|
||||
if (!canAccess(permissions, PERMS.DEVOPS_VIEW, session.user.rank)) {
|
||||
redirect("/admin");
|
||||
redirect('/admin')
|
||||
}
|
||||
|
||||
const data = await getDevOpsData();
|
||||
const data = await getDevOpsData()
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -72,8 +72,8 @@ export default async function DevOpsPage() {
|
||||
<Database className="h-4 w-4 text-muted-foreground" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Badge variant={data.dbStatus === "healthy" ? "default" : "destructive"}>
|
||||
{data.dbStatus === "healthy" ? "Healthy" : "Error"}
|
||||
<Badge variant={data.dbStatus === 'healthy' ? 'default' : 'destructive'}>
|
||||
{data.dbStatus === 'healthy' ? 'Healthy' : 'Error'}
|
||||
</Badge>
|
||||
<p className="text-xs text-muted-foreground mt-1">Latency: {data.dbLatency}ms</p>
|
||||
</CardContent>
|
||||
@@ -134,7 +134,7 @@ export default async function DevOpsPage() {
|
||||
</span>
|
||||
</div>
|
||||
<pre className="text-xs whitespace-pre-wrap break-all font-mono text-destructive">
|
||||
{Buffer.from(error.stacktrace).toString("utf-8")}
|
||||
{Buffer.from(error.stacktrace).toString('utf-8')}
|
||||
</pre>
|
||||
</div>
|
||||
))}
|
||||
@@ -143,5 +143,5 @@ export default async function DevOpsPage() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user