Skip to content

Commit 63a3a60

Browse files
authored
feat: improve slack feedback (#3433)
1 parent bc3ca29 commit 63a3a60

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ The migration generator compares entities against the local database schema. Ens
136136
- Subscribers fetch their own data - don't optimize topic payloads for specific consumers
137137
- This allows multiple subscribers with different data needs
138138

139+
**Avoid magic numbers for time durations:**
140+
- Use time constants from `src/common/constants.ts` instead of inline calculations
141+
- Available constants: `ONE_MINUTE_IN_SECONDS`, `ONE_HOUR_IN_SECONDS`, `ONE_DAY_IN_SECONDS`, `ONE_WEEK_IN_SECONDS`, `ONE_MONTH_IN_SECONDS`, `ONE_YEAR_IN_SECONDS`, `ONE_HOUR_IN_MINUTES`, `ONE_DAY_IN_MINUTES`
142+
- Example: Use `2 * ONE_DAY_IN_MINUTES` instead of `2 * 24 * 60`
143+
- Add new constants to `src/common/constants.ts` if needed (they are re-exported from `src/common/index.ts`)
144+
139145
## Best Practices & Lessons Learned
140146

141147
**Avoiding Code Duplication:**

src/common/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export const ONE_WEEK_IN_SECONDS = ONE_DAY_IN_SECONDS * 7;
55
export const ONE_MONTH_IN_SECONDS = ONE_DAY_IN_SECONDS * 30;
66
export const ONE_YEAR_IN_SECONDS = ONE_DAY_IN_SECONDS * 365;
77

8+
export const ONE_HOUR_IN_MINUTES = 60;
9+
export const ONE_DAY_IN_MINUTES = ONE_HOUR_IN_MINUTES * 24;
10+
811
export const THREE_MONTHS_IN_SECONDS = ONE_MONTH_IN_SECONDS * 3;
912

1013
export const MAX_FOLLOWERS_LIMIT = 5_000;

src/workers/candidateReviewOpportunitySlack.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ApplicationScored } from '@dailydotdev/schema';
22
import { TypedWorker } from './worker';
3-
import { truncateText, webhooks } from '../common';
3+
import { ONE_DAY_IN_MINUTES, truncateText, webhooks } from '../common';
44
import { generateResumeSignedUrl } from '../common/googleCloud';
55
import { OpportunityMatch } from '../entity/OpportunityMatch';
66
import { OpportunityJob } from '../entity/opportunities/OpportunityJob';
@@ -13,7 +13,12 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
1313
handler: async ({ data }, con): Promise<void> => {
1414
if (process.env.NODE_ENV === 'development') return;
1515

16-
const { opportunityId, userId } = data;
16+
const {
17+
opportunityId,
18+
userId,
19+
score: applicationScore,
20+
description,
21+
} = data;
1722
const match = await con.getRepository(OpportunityMatch).findOne({
1823
where: { opportunityId, userId },
1924
relations: ['opportunity', 'user'],
@@ -42,10 +47,9 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
4247
const salary = pref?.salaryExpectation;
4348
const cv = pref?.cv;
4449
const cvSignedUrl = cv?.blob
45-
? await generateResumeSignedUrl(cv.blob)
50+
? await generateResumeSignedUrl(cv.blob, 2 * ONE_DAY_IN_MINUTES)
4651
: null;
4752
const matchScore = match.description?.matchScore;
48-
const applicationScore = match.applicationRank?.score;
4953

5054
await webhooks.recruiterReview.send({
5155
blocks: [
@@ -113,13 +117,13 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
113117
text: `*CV:*\n${cvSignedUrl ? `<${cvSignedUrl}|Download CV>` : 'N/A'}`,
114118
},
115119
},
116-
...(match.applicationRank?.description
120+
...(description
117121
? [
118122
{
119123
type: 'section' as const,
120124
text: {
121125
type: 'mrkdwn' as const,
122-
text: `*Application Summary:*\n${truncateText(match.applicationRank.description)}`,
126+
text: `*Application Summary:*\n${truncateText(description)}`,
123127
},
124128
},
125129
]

0 commit comments

Comments
 (0)