node-cron schedules runSync at 03:00 local time; runSync enqueues sync.source_doc for every source_docs row with sync_source='url'. Started from server.js's CLI gate alongside the job queue. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
13 lines
340 B
JavaScript
13 lines
340 B
JavaScript
import { pool } from '../db/pool.js';
|
|
import * as queue from '../jobs/queue.js';
|
|
|
|
export async function runSync() {
|
|
const { rows } = await pool.query(
|
|
`SELECT id FROM source_docs WHERE sync_source = 'url'`
|
|
);
|
|
for (const r of rows) {
|
|
await queue.enqueue('sync.source_doc', { source_doc_id: r.id });
|
|
}
|
|
return rows.length;
|
|
}
|