Skip to content

Commit e07d9f9

Browse files
committed
Reclassify rejection feedback on subsequent submissions
1 parent 8a16150 commit e07d9f9

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

__tests__/workers/opportunity/parseOpportunityFeedback.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe('parseOpportunityFeedback worker', () => {
277277
});
278278
});
279279

280-
it('should skip classifyRejectionFeedback when already classified', async () => {
280+
it('should reclassify when already classified', async () => {
281281
await con.getRepository(OpportunityMatch).save({
282282
opportunityId: testOpportunityId,
283283
userId: '1',
@@ -299,6 +299,20 @@ describe('parseOpportunityFeedback worker', () => {
299299
},
300300
});
301301

302+
mockClassifyRejectionFeedback.mockResolvedValue({
303+
id: 'test-id',
304+
classification: {
305+
reasons: [
306+
{
307+
reason: 5,
308+
confidence: 0.91,
309+
explanation: 'Candidate prefers another area',
310+
},
311+
],
312+
summary: 'Updated classification',
313+
},
314+
});
315+
302316
await expectSuccessfulTypedBackground<'api.v1.opportunity-feedback-submitted'>(
303317
worker,
304318
{
@@ -307,7 +321,22 @@ describe('parseOpportunityFeedback worker', () => {
307321
},
308322
);
309323

310-
expect(mockClassifyRejectionFeedback).not.toHaveBeenCalled();
324+
expect(mockClassifyRejectionFeedback).toHaveBeenCalled();
325+
326+
const updatedMatch = await con.getRepository(OpportunityMatch).findOne({
327+
where: { opportunityId: testOpportunityId, userId: '1' },
328+
});
329+
330+
expect(updatedMatch?.rejectionClassification).toEqual({
331+
reasons: [
332+
{
333+
reason: 5,
334+
confidence: 0.91,
335+
explanation: 'Candidate prefers another area',
336+
},
337+
],
338+
summary: 'Updated classification',
339+
});
311340
});
312341

313342
it('should handle ConnectError from classifyRejectionFeedback gracefully', async () => {

src/workers/opportunity/parseOpportunityFeedback.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,6 @@ const parseOpportunityFeedback = async ({
9393
'Successfully parsed opportunity feedback',
9494
);
9595

96-
const hasRejectionClassification =
97-
!!match.rejectionClassification &&
98-
Array.isArray(match.rejectionClassification.reasons) &&
99-
typeof match.rejectionClassification.summary === 'string';
100-
101-
if (hasRejectionClassification) {
102-
logger.debug(
103-
{ opportunityId, userId },
104-
'Rejection feedback already classified',
105-
);
106-
return;
107-
}
108-
10996
try {
11097
const feedback = match.feedback
11198
.map((item) => `Q: ${item.screening}\nA: ${item.answer}`)

0 commit comments

Comments
 (0)