2026-09-01 16:31:40 +08:00
|
|
|
|
/* poll-review-tasks.cjs — 轮询 6 条复盘任务(/api/run/status,ACCEPTED 已归 done)*/
|
|
|
|
|
|
const TASKS = [
|
|
|
|
|
|
{ rw: 31, id: 'automation-1788251452496' },
|
|
|
|
|
|
{ rw: 30, id: 'automation-1788251455526' },
|
|
|
|
|
|
{ rw: 29, id: 'automation-1788251458549' },
|
|
|
|
|
|
{ rw: 28, id: 'automation-1788251461578' },
|
|
|
|
|
|
{ rw: 27, id: 'automation-1788251464600' },
|
|
|
|
|
|
{ rw: 26, id: 'automation-1788251467630' },
|
|
|
|
|
|
];
|
2026-09-10 18:28:42 +08:00
|
|
|
|
const { loadConfig } = require('./load-config');
|
|
|
|
|
|
const CFG = loadConfig();
|
|
|
|
|
|
const API = `http://localhost:${CFG.port}/api/run/status?id=`;
|
2026-09-01 16:31:40 +08:00
|
|
|
|
const state = {};
|
|
|
|
|
|
TASKS.forEach((t) => (state[t.rw] = 'pending'));
|
|
|
|
|
|
const status = async (id) => {
|
|
|
|
|
|
try {
|
2026-09-10 18:28:42 +08:00
|
|
|
|
const r = await fetch(API + encodeURIComponent(id));
|
2026-09-01 16:31:40 +08:00
|
|
|
|
const d = await r.json();
|
|
|
|
|
|
return d.state || 'unknown';
|
|
|
|
|
|
} catch { return 'unknown'; }
|
|
|
|
|
|
};
|
|
|
|
|
|
console.log('START polling 6 review tasks:', new Date().toLocaleTimeString('zh-CN'));
|
2026-09-01 18:33:20 +08:00
|
|
|
|
(async () => {
|
2026-09-01 16:31:40 +08:00
|
|
|
|
const started = Date.now();
|
|
|
|
|
|
while (Date.now() - started < 60 * 60 * 1000) {
|
|
|
|
|
|
let allDone = true;
|
|
|
|
|
|
for (const t of TASKS) {
|
|
|
|
|
|
const s = await status(t.id);
|
|
|
|
|
|
state[t.rw] = s;
|
|
|
|
|
|
if (s !== 'done' && s !== 'error') allDone = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log(new Date().toLocaleTimeString('zh-CN'), '|',
|
|
|
|
|
|
TASKS.map((t) => 'rw' + t.rw + ':' + state[t.rw]).join(' '));
|
|
|
|
|
|
if (allDone) {
|
|
|
|
|
|
const errs = TASKS.filter((t) => state[t.rw] === 'error');
|
|
|
|
|
|
console.log(errs.length ? 'ALL DONE (with errors): ' + errs.map((t) => 'rw' + t.rw).join(',') : 'ALL DONE ✓');
|
|
|
|
|
|
process.exit(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
await new Promise((r) => setTimeout(r, 30000));
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log('TIMEOUT after 60min, last states:', JSON.stringify(state));
|
|
|
|
|
|
process.exit(1);
|
2026-09-01 18:33:20 +08:00
|
|
|
|
})();
|