Prioritize growth retries and randomize intake

This commit is contained in:
jjbrunton committed 2026-08-11 21:14:30 +01:00
1 parent b949b6ee37
commit e2d7dc4b82
11 files changed
+142 -4

No files matched your search

+7 -1
View File
@@ -196,6 +196,9 @@ export class AccountGrowthService {
let claimed = this.repository.claimNext(this.accountId, this.workerId, LEASE_MS, now);
if (!claimed) {
if (this.repository.hasPendingQueueWork(this.accountId)) {
return { kind: 'idle', reason: 'Existing growth queue is waiting for its retry time' };
}
const discovery = await this.discover(signal);
if (discovery.kind === 'idle') return discovery;
claimed = this.repository.claimNext(this.accountId, this.workerId, LEASE_MS, this.now());
@@ -241,7 +244,10 @@ export class AccountGrowthService {
else rejections.set(screening.reason, (rejections.get(screening.reason) ?? 0) + 1);
}
const intake = this.repository.enqueueDiscovered(this.accountId, eligible, now, 10);
// Queue one thread at a time. Subreddit selection is randomized on every
// new unit of work, rather than one random community producing a long,
// predictable run of comments from a ten-thread batch.
const intake = this.repository.enqueueDiscovered(this.accountId, eligible, now, 1);
this.logger.info(
`Growth intake r/${subreddit.subreddit} for u/${this.options.redditUsername}: `
+ `${posts.length} fetched; ${eligible.length} eligible; ${intake.discovered} queued; `