全项目扫描修复: Docker数据卷修复+安全requireAdmin+12页SEO+API白名单+脚本超时+常量提取+假数据删除
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
||||
import "dotenv/config";
|
||||
|
||||
const base = process.env.DATABASE_URL.replace("mysql://", "mariadb://");
|
||||
const cs = base + (base.includes("?") ? "&" : "?") + "connection_limit=5";
|
||||
const prisma = new PrismaClient({ adapter: new PrismaMariaDb(cs) });
|
||||
|
||||
const total = await prisma.forumTopic.count();
|
||||
const last10 = await prisma.forumTopic.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 10,
|
||||
include: { category: { select: { name: true, slug: true } } }
|
||||
});
|
||||
const catCount = await prisma.forumCategory.count();
|
||||
console.log("总话题数:", total);
|
||||
console.log("总板块数:", catCount);
|
||||
console.log("\n最近10个话题:");
|
||||
for (const t of last10) {
|
||||
console.log(" [" + t.createdAt.toISOString() + "]", t.category?.name || "无板块", "|", t.title.substring(0, 50));
|
||||
}
|
||||
const oneDayAgo = new Date(Date.now() - 24 * 3600 * 1000);
|
||||
const recent = await prisma.forumTopic.count({ where: { createdAt: { gt: oneDayAgo } } });
|
||||
console.log("\n过去24小时新话题:", recent);
|
||||
|
||||
const byCat = await prisma.forumCategory.findMany({
|
||||
include: { _count: { select: { topics: true } } },
|
||||
orderBy: { sortOrder: "asc" }
|
||||
});
|
||||
console.log("\n各板块话题数:");
|
||||
for (const c of byCat) {
|
||||
if (c._count.topics > 0) console.log(" " + c.name + ": " + c._count.topics);
|
||||
}
|
||||
const empty = byCat.filter(c => c._count.topics === 0);
|
||||
console.log("\n空板块数:", empty.length);
|
||||
if (empty.length > 0 && empty.length < 10) {
|
||||
console.log("空板块列表:", empty.map(c => c.name).join(", "));
|
||||
}
|
||||
|
||||
await prisma.$disconnect();
|
||||
Reference in New Issue
Block a user