fix: 定时任务修复+管理后台Task7支持 (Task4外键修复, Task7管理员邮箱动态查询, Task5限流防护, Task7加入SCRIPT_MAP)

This commit is contained in:
ZhuiGuangAI Dev
2026-05-30 18:03:48 +08:00
parent 4d5e7266b5
commit 10d1acb305
56 changed files with 2779 additions and 135 deletions
+36
View File
@@ -0,0 +1,36 @@
const fs = require('fs');
const path = require('path');
const scriptsDir = '/home/ubuntu/zhuiguang-ai/scripts';
const files = fs.readdirSync(scriptsDir).filter(f => f.endsWith('.mjs'));
const oldLine = 'const base = process.env.DATABASE_URL || "mysql://localhost:3306/zhuiguang_ai?charset=utf8mb4";';
const newLine = 'const base = (process.env.DATABASE_URL || "mysql://localhost:3306/zhuiguang_ai?charset=utf8mb4").replace("mysql://", "mariadb://");';
let fixed = 0;
let skipped = 0;
for (const file of files) {
const filePath = path.join(scriptsDir, file);
let content = fs.readFileSync(filePath, 'utf8');
if (content.includes('PrismaMariaDb') && content.includes(oldLine)) {
content = content.replace(oldLine, newLine);
fs.writeFileSync(filePath, content, 'utf8');
console.log('Fixed: ' + file);
fixed++;
} else if (content.includes('PrismaMariaDb')) {
console.log('Skipped (already fixed or different pattern): ' + file);
skipped++;
}
}
console.log('\nTotal fixed: ' + fixed + ', skipped: ' + skipped);
console.log('\n=== Verification ===');
// Show the fixed lines
const verifyFiles = ['task5-update-stars.mjs', 'task1-discover-tools.mjs', 'daily-news.mjs', 'task7-news-to-community.mjs'];
for (const f of verifyFiles) {
const content = fs.readFileSync(path.join(scriptsDir, f), 'utf8');
const match = content.match(/const base = .*/);
if (match) console.log(f + ': ' + match[0]);
}