Show waiting tasks accurately in operations views

This commit is contained in:
wuyang
2026-11-05 11:02:42 +08:00
parent f882c9a831
commit 5e7cae0bee
5 changed files with 27 additions and 10 deletions
+2 -2
View File
@@ -164,10 +164,10 @@ export function createApp(options = process.env) {
if (req.method === 'GET' && route === '/api/workqueue') {
const value = await jsonFile('workqueue.json', { schema: 1, tasks: [] });
if (value?.schema !== 1 || !Array.isArray(value.tasks)) return json(res, 500, { error: '工作队列格式无效' });
const valid = new Set(['pending', 'running', 'done', 'blocked']);
const valid = new Set(['pending', 'running', 'waiting', 'done', 'blocked']);
const categories = new Set(['content', 'engineering', 'research', 'community', 'management']);
const tasks = value.tasks.filter(t => t && typeof t.id === 'string' && typeof t.title === 'string' && valid.has(t.status))
.map(t => ({ title: t.id.startsWith('interaction-') ? '核查新互动' : t.title.slice(0, 100), status: t.status,
.map(t => ({ title: t.id.startsWith('interaction-') ? '核查新互动' : t.title.slice(0, 100), status: t.status === 'pending' && t.dispatch_ready !== true ? 'waiting' : t.status,
category: categories.has(t.category) ? t.category : 'management', attempts: Number.isInteger(t.attempts) ? t.attempts : 0, updated_at: typeof t.updated_at === 'string' ? t.updated_at : null }));
return json(res, 200, { tasks });
}