Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ The migration generator compares entities against the local database schema. Ens
- Subscribers fetch their own data - don't optimize topic payloads for specific consumers
- This allows multiple subscribers with different data needs

**Avoid magic numbers for time durations:**
- Use time constants from `src/common/constants.ts` instead of inline calculations
- 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`
- Example: Use `2 * ONE_DAY_IN_MINUTES` instead of `2 * 24 * 60`
- Add new constants to `src/common/constants.ts` if needed (they are re-exported from `src/common/index.ts`)

## Best Practices & Lessons Learned

**Avoiding Code Duplication:**
Expand Down
3 changes: 3 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export const ONE_WEEK_IN_SECONDS = ONE_DAY_IN_SECONDS * 7;
export const ONE_MONTH_IN_SECONDS = ONE_DAY_IN_SECONDS * 30;
export const ONE_YEAR_IN_SECONDS = ONE_DAY_IN_SECONDS * 365;

export const ONE_HOUR_IN_MINUTES = 60;
export const ONE_DAY_IN_MINUTES = ONE_HOUR_IN_MINUTES * 24;

export const THREE_MONTHS_IN_SECONDS = ONE_MONTH_IN_SECONDS * 3;

export const MAX_FOLLOWERS_LIMIT = 5_000;
Expand Down
16 changes: 10 additions & 6 deletions src/workers/candidateReviewOpportunitySlack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApplicationScored } from '@dailydotdev/schema';
import { TypedWorker } from './worker';
import { truncateText, webhooks } from '../common';
import { ONE_DAY_IN_MINUTES, truncateText, webhooks } from '../common';
import { generateResumeSignedUrl } from '../common/googleCloud';
import { OpportunityMatch } from '../entity/OpportunityMatch';
import { OpportunityJob } from '../entity/opportunities/OpportunityJob';
Expand All @@ -13,7 +13,12 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
handler: async ({ data }, con): Promise<void> => {
if (process.env.NODE_ENV === 'development') return;

const { opportunityId, userId } = data;
const {
opportunityId,
userId,
score: applicationScore,
description,
} = data;
const match = await con.getRepository(OpportunityMatch).findOne({
where: { opportunityId, userId },
relations: ['opportunity', 'user'],
Expand Down Expand Up @@ -42,10 +47,9 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
const salary = pref?.salaryExpectation;
const cv = pref?.cv;
const cvSignedUrl = cv?.blob
? await generateResumeSignedUrl(cv.blob)
? await generateResumeSignedUrl(cv.blob, 2 * ONE_DAY_IN_MINUTES)
: null;
const matchScore = match.description?.matchScore;
const applicationScore = match.applicationRank?.score;

await webhooks.recruiterReview.send({
blocks: [
Expand Down Expand Up @@ -113,13 +117,13 @@ const worker: TypedWorker<'gondul.v1.candidate-application-scored'> = {
text: `*CV:*\n${cvSignedUrl ? `<${cvSignedUrl}|Download CV>` : 'N/A'}`,
},
},
...(match.applicationRank?.description
...(description
? [
{
type: 'section' as const,
text: {
type: 'mrkdwn' as const,
text: `*Application Summary:*\n${truncateText(match.applicationRank.description)}`,
text: `*Application Summary:*\n${truncateText(description)}`,
},
},
]
Expand Down
Loading