feat: configure ready outreach funnel limit
This commit is contained in:
1 parent
22eb32e5bf
commit
e9083281a8
15 files changed
+66
-11
No files matched your search
@@ -191,12 +191,22 @@ export class CandidateQueueRepository {
|
||||
`).run(now, postId, workerId).changes === 1;
|
||||
}
|
||||
|
||||
promoteDueRetries(now: number = Date.now()): number {
|
||||
promoteDueRetries(maxReadyCandidates: number, now: number = Date.now()): number {
|
||||
if (!Number.isInteger(maxReadyCandidates) || maxReadyCandidates < 1) {
|
||||
throw new Error('Maximum ready candidates must be a positive integer');
|
||||
}
|
||||
const capacity = maxReadyCandidates - this.countReady();
|
||||
if (capacity <= 0) return 0;
|
||||
return this.db.prepare(`
|
||||
UPDATE candidate_queue
|
||||
SET status = 'ready', updated_at = ?, assigned_account_id = NULL
|
||||
WHERE status = 'retryable' AND available_at <= ?
|
||||
`).run(now, now).changes;
|
||||
WHERE post_id IN (
|
||||
SELECT post_id FROM candidate_queue
|
||||
WHERE status = 'retryable' AND available_at <= ?
|
||||
ORDER BY priority DESC, discovered_at ASC
|
||||
LIMIT ?
|
||||
)
|
||||
`).run(now, now, capacity).changes;
|
||||
}
|
||||
|
||||
recoverExpiredLeases(now: number = Date.now(), sendingDelayMs = 10 * 60_000): number {
|
||||
|
||||
Reference in new issue
Block a user