Skip to content

Commit 2d3fe2b

Browse files
committed
feat: make sure we only save part of userIds
1 parent 5bfc288 commit 2d3fe2b

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

__tests__/workers/opportunity/opportunityPreviewResult.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,26 @@ describe('opportunityPreviewResult worker', () => {
6666
),
6767
).rejects.toThrow('Missing opportunityId in opportunity preview result');
6868
});
69+
70+
it('should save only first 20 userIds', async () => {
71+
const applicationScoreData = new OpportunityPreviewResult({
72+
opportunityId: '550e8400-e29b-41d4-a716-446655440001',
73+
userIds: new Array(25).fill(undefined).map((_, i) => `${i + 1}`),
74+
totalCount: 3,
75+
});
76+
77+
await expectSuccessfulTypedBackground<'gondul.v1.opportunity-preview-results'>(
78+
worker,
79+
applicationScoreData,
80+
);
81+
82+
const opportunity = await con.getRepository(OpportunityJob).findOne({
83+
where: {
84+
id: '550e8400-e29b-41d4-a716-446655440001',
85+
},
86+
});
87+
88+
expect(opportunity).toBeDefined();
89+
expect(opportunity!.flags.preview?.userIds.length).toBe(20);
90+
});
6991
});

src/workers/opportunity/opportunityPreviewResult.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const opportunityPreviewResultWorker: TypedWorker<'gondul.v1.opportunity-
2121
{
2222
flags: updateFlagsStatement<OpportunityJob>({
2323
preview: {
24-
userIds,
24+
userIds: userIds.slice(0, 20),
2525
totalCount,
2626
status: OpportunityPreviewStatus.READY,
2727
},

0 commit comments

Comments
 (0)