fix(admin): 手动触发同步同时跑 AI OKR 分析
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
之前 /admin/sync/trigger 只调用 syncGitea,导致 UI 上点"触发同步" 按钮无论多少次,OKR 都不会被更新。改为同步完成后立即跑 AI 分析, 逻辑与 scheduler.ts 的定时任务保持一致。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0dcb9c02d3
commit
8561f6190d
@ -336,11 +336,22 @@ adminRoutes.put('/admin/users/:id/projects', zValidator('json', setUserProjectsS
|
||||
|
||||
adminRoutes.post('/admin/sync/trigger', async (c) => {
|
||||
const { syncGitea } = await import('../sync/sync-gitea');
|
||||
const { analyzeCommitsForOKR } = await import('../services/okr-ai-sync');
|
||||
const { config } = await import('../config');
|
||||
// 异步执行,不阻塞响应
|
||||
syncGitea().catch(err => console.error('[SYNC] Manual trigger failed:', err));
|
||||
(async () => {
|
||||
try {
|
||||
await syncGitea();
|
||||
if (config.AI_ENABLED && config.AI_API_KEY) {
|
||||
await analyzeCommitsForOKR();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[SYNC] Manual trigger failed:', err);
|
||||
}
|
||||
})();
|
||||
return c.json({
|
||||
code: 0,
|
||||
data: { message: '同步已触发,请稍后刷新查看结果' },
|
||||
data: { message: '同步 + AI 分析已触发,请稍后刷新查看结果' },
|
||||
message: 'success',
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user