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

+27
View File
@@ -295,6 +295,33 @@ describe('AccountGrowthRepository', () => {
expect(repo.claimNext(ACCOUNT, 'worker-1', 60_000, 5_000)?.postId).toBe('a');
});
it('claims a due retry before a newer untouched thread', () => {
repo.enqueueDiscovered(ACCOUNT, [
thread('retry', { created_utc: 1_000 }),
thread('newer', { created_utc: 9_000 }),
], 10_000);
repo.claimNext(ACCOUNT, 'worker-1', 60_000, 10_000);
repo.defer(ACCOUNT, 'newer', 'worker-1', 'Temporary failure', 11_000, 10_000);
repo.enqueueDiscovered(ACCOUNT, [thread('newest', { created_utc: 12_000 })], 12_000);
expect(repo.claimNext(ACCOUNT, 'worker-1', 60_000, 12_000)?.postId).toBe('newer');
});
it('reports and clears only pending queue work', () => {
repo.enqueueDiscovered(ACCOUNT, [
thread('queued', { created_utc: 1_000 }),
thread('posted', { created_utc: 2_000 }),
], 1_000);
repo.claimNext(ACCOUNT, 'worker-1', 60_000, 1_000);
repo.defer(ACCOUNT, 'posted', 'worker-1', 'Temporary failure', 5_000, 1_500);
expect(repo.hasPendingQueueWork(ACCOUNT)).toBe(true);
expect(repo.clearPendingQueue(ACCOUNT)).toBe(2);
expect(repo.hasPendingQueueWork(ACCOUNT)).toBe(false);
expect(repo.listRecent(ACCOUNT)).toEqual([]);
});
it('rejects rather than retries a comment interrupted mid-post', () => {
repo.enqueueDiscovered(ACCOUNT, [thread('a')], 1_000);
repo.claimNext(ACCOUNT, 'worker-1', 60_000, 1_000);