feat: 全面优化系统 - 修复task1语法错误 + Bot超时保护 + 熔断重试 + Redis缓存 + SEO + 日志清理 + 内容质量评估

This commit is contained in:
ZhuiGuangAI Dev
2026-06-13 15:26:39 +08:00
parent a0a60ee9dc
commit b44601bb66
12 changed files with 399 additions and 12 deletions
+70
View File
@@ -0,0 +1,70 @@
import { PrismaClient } from "@prisma/client";
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
import "dotenv/config";
const base = process.env.DATABASE_URL.replace("mysql://", "mariadb://");
const sep = base.includes("?") ? "&" : "?";
const connectionString = `${base}${sep}connection_limit=10&pool_timeout=30`;
const adapter = new PrismaMariaDb(connectionString);
const prisma = new PrismaClient({ adapter });
async function check() {
const botCount = await prisma.user.count({ where: { isBot: true } });
const topicCount = await prisma.forumTopic.count({ where: { user: { isBot: true } } });
const postCount = await prisma.forumPost.count({ where: { user: { isBot: true } } });
const likeCount = await prisma.commentLike.count({ where: { user: { isBot: true } } });
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayTopics = await prisma.forumTopic.count({ where: { user: { isBot: true }, createdAt: { gte: today } } });
const todayPosts = await prisma.forumPost.count({ where: { user: { isBot: true }, createdAt: { gte: today } } });
const variants = await prisma.botPersonaVariant.count();
const experiments = await prisma.botPersonaExperiment.count();
const assignments = await prisma.botPersonaAssignment.count();
const learnings = await prisma.botAdversarialLearning.count();
const activeLearnings = await prisma.botAdversarialLearning.count({ where: { status: "active" } });
const skills = await prisma.botSkill.count();
const activeSkills = await prisma.botSkill.count({ where: { isActive: true } });
const dailyStats = await prisma.botDailyStat.groupBy({
by: ["date"],
_sum: { topicCreated: true, replySent: true, followUpSent: true, repliesReceived: true },
orderBy: { date: "desc" },
take: 7
});
const humanTopics = await prisma.forumTopic.count({ where: { user: { isBot: false } } });
const humanPosts = await prisma.forumPost.count({ where: { user: { isBot: false } } });
console.log("=== BOT STATS ===");
console.log("Bot users:", botCount);
console.log("Bot topics:", topicCount);
console.log("Bot posts:", postCount);
console.log("Bot likes:", likeCount);
console.log("Today topics:", todayTopics);
console.log("Today posts:", todayPosts);
console.log("Human topics:", humanTopics);
console.log("Human posts:", humanPosts);
console.log("Bot/Human topic ratio:", humanTopics > 0 ? (topicCount / humanTopics).toFixed(2) : "N/A");
console.log("Bot/Human post ratio:", humanPosts > 0 ? (postCount / humanPosts).toFixed(2) : "N/A");
console.log("\n=== A/B EXPERIMENTS ===");
console.log("Variants:", variants);
console.log("Experiments:", experiments);
console.log("Assignments:", assignments);
console.log("\n=== ADVERSARIAL LEARNING ===");
console.log("Total learnings:", learnings);
console.log("Active learnings:", activeLearnings);
console.log("\n=== SKILL CRYSTALLIZATION ===");
console.log("Total skills:", skills);
console.log("Active skills:", activeSkills);
console.log("\n=== DAILY STATS (last 7 days) ===");
dailyStats.forEach(d => {
console.log(`${d.date.toISOString().split("T")[0]}: topics=${d._sum.topicsCreated||0} posts=${d._sum.postsCreated||0} likes=${d._sum.likesReceived||0} human_interactions=${d._sum.humanInteractions||0}`);
});
await prisma.$disconnect();
}
check().catch(e => { console.error(e); process.exit(1); });