Skip to content

Commit 8a16150

Browse files
committed
Align rejection classification default and guard semantics
1 parent b1235e4 commit 8a16150

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

__tests__/workers/opportunity/parseOpportunityFeedback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ describe('parseOpportunityFeedback worker', () => {
348348
where: { opportunityId: testOpportunityId, userId: '1' },
349349
});
350350

351-
// Rejection classification should be null (error was handled gracefully)
352-
expect(updatedMatch?.rejectionClassification).toBeNull();
351+
// Rejection classification should remain empty JSON (error was handled gracefully)
352+
expect(updatedMatch?.rejectionClassification).toEqual({});
353353
// But per-item feedback classification should still be stored
354354
expect(updatedMatch?.feedback?.[0]?.classification).toBeDefined();
355355
});

src/migration/1770812936388-AddRejectionClassificationToOpportunityMatch.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export class AddRejectionClassificationToOpportunityMatch1770812936388
1010
`ALTER TABLE "opportunity_match"
1111
ADD COLUMN IF NOT EXISTS "rejectionClassification" jsonb`,
1212
);
13+
await queryRunner.query(
14+
`ALTER TABLE "opportunity_match"
15+
ALTER COLUMN "rejectionClassification" SET DEFAULT '{}'::jsonb`,
16+
);
1317
}
1418

1519
public async down(queryRunner: QueryRunner): Promise<void> {

src/workers/opportunity/parseOpportunityFeedback.ts

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

96-
if (match.rejectionClassification) {
96+
const hasRejectionClassification =
97+
!!match.rejectionClassification &&
98+
Array.isArray(match.rejectionClassification.reasons) &&
99+
typeof match.rejectionClassification.summary === 'string';
100+
101+
if (hasRejectionClassification) {
97102
logger.debug(
98103
{ opportunityId, userId },
99104
'Rejection feedback already classified',

0 commit comments

Comments
 (0)