Prioritize growth retries and randomize intake
This commit is contained in:
1 parent
b949b6ee37
commit
e2d7dc4b82
11 files changed
+142
-4
No files matched your search
@@ -295,6 +295,36 @@ describe('AccountGrowthService', () => {
|
||||
expect(outcome).toMatchObject({ kind: 'idle' });
|
||||
expect(h.postComment).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('waits for a queued retry instead of discovering another thread', async () => {
|
||||
h.repo.enqueueDiscovered(ACCOUNT, [thread('retry')], NOW);
|
||||
h.repo.claimNext(ACCOUNT, `growth:${ACCOUNT}`, 60_000, NOW);
|
||||
h.repo.defer(
|
||||
ACCOUNT,
|
||||
'retry',
|
||||
`growth:${ACCOUNT}`,
|
||||
'Temporary generation failure',
|
||||
NOW + 15 * 60_000,
|
||||
NOW,
|
||||
);
|
||||
|
||||
const outcome = await h.service.tick({ allowPosting: true });
|
||||
|
||||
expect(outcome).toEqual({
|
||||
kind: 'idle',
|
||||
reason: 'Existing growth queue is waiting for its retry time',
|
||||
});
|
||||
expect(h.getHotPosts).not.toHaveBeenCalled();
|
||||
expect(h.repo.listRecent(ACCOUNT)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('queues only one thread so each new comment rerolls the subreddit', async () => {
|
||||
h.getHotPosts.mockResolvedValue([thread('a'), thread('b'), thread('c')]);
|
||||
|
||||
await h.service.tick({ allowPosting: true });
|
||||
|
||||
expect(h.repo.listRecent(ACCOUNT)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('posting', () => {
|
||||
|
||||
Reference in new issue
Block a user