Skip to content

Commit 984c4bd

Browse files
committed
feat: indicate self apply on candidate match
1 parent 65c03ae commit 984c4bd

File tree

6 files changed

+39
-11
lines changed

6 files changed

+39
-11
lines changed

__tests__/schema/opportunity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3029,7 +3029,9 @@ describe('mutation opportunityApply', () => {
30293029
description: {},
30303030
screening: [],
30313031
feedback: [],
3032-
applicationRank: {},
3032+
applicationRank: {
3033+
selfApplied: true,
3034+
},
30333035
});
30343036
});
30353037

__tests__/workers/opportunity/storeCandidateApplicationScore.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ describe('storeCandidateApplicationScore worker', () => {
6060
await con.getRepository(OpportunityMatch).save({
6161
userId: '1',
6262
opportunityId: '550e8400-e29b-41d4-a716-446655440001',
63-
applicationRank: { score: 60, description: 'Previous score' },
63+
applicationRank: {
64+
score: 60,
65+
description: 'Previous score',
66+
selfApplied: true,
67+
},
6468
});
6569

6670
const updatedScoreData = new ApplicationScored({
@@ -86,6 +90,7 @@ describe('storeCandidateApplicationScore worker', () => {
8690
expect(match?.applicationRank).toEqual({
8791
score: 90,
8892
description: 'Updated score after review',
93+
selfApplied: true,
8994
});
9095
});
9196

src/common/schema/opportunities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const applicationScoreSchema = z.object({
2828
score: z.number().min(0).max(100).optional(),
2929
description: z.string().optional(),
3030
warmIntro: z.string().optional(),
31+
selfApplied: z.boolean().optional(),
3132
});
3233

3334
export const opportunityContentSchema = z.object({

src/schema/opportunity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,9 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
30633063
description: {},
30643064
screening: [],
30653065
feedback: [],
3066-
applicationRank: {},
3066+
applicationRank: {
3067+
selfApplied: true,
3068+
},
30673069
}),
30683070
);
30693071

src/workers/candidateReviewOpportunitySlack.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
110110
text: `*Skills:*\n${keywords.map((k) => k.keyword).join(', ') || 'N/A'}`,
111111
},
112112
},
113+
{
114+
type: 'section',
115+
text: {
116+
type: 'mrkdwn',
117+
text: `*Self applied:*\n${match.applicationRank?.selfApplied ? 'Yes' : 'No'}`,
118+
},
119+
},
113120
{
114121
type: 'section',
115122
text: {

src/workers/opportunity/storeCandidateApplicationScore.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,28 @@ export const storeCandidateApplicationScore: TypedWorker<'gondul.v1.candidate-ap
3030
description,
3131
});
3232

33-
await con.getRepository(OpportunityMatch).upsert(
34-
{
33+
const matchExists = await con.getRepository(OpportunityMatch).exists({
34+
where: { userId, opportunityId },
35+
});
36+
37+
if (matchExists) {
38+
await con.getRepository(OpportunityMatch).update(
39+
{
40+
userId,
41+
opportunityId,
42+
},
43+
{
44+
applicationRank: () =>
45+
`"applicationRank" || '${JSON.stringify(applicationRank)}'`,
46+
},
47+
);
48+
} else {
49+
await con.getRepository(OpportunityMatch).insert({
3550
userId,
3651
opportunityId,
3752
applicationRank,
38-
},
39-
{
40-
conflictPaths: ['userId', 'opportunityId'],
41-
skipUpdateIfNoValuesChanged: true,
42-
},
43-
);
53+
});
54+
}
4455
},
4556
parseMessage: (message) => ApplicationScored.fromBinary(message.data),
4657
};

0 commit comments

Comments
 (0)