Skip to content

Commit

Permalink
revert and fix cursed bind commit
Browse files Browse the repository at this point in the history
  • Loading branch information
john-tco committed Oct 24, 2023
1 parent 4a570f8 commit 610c9da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/notifications/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class NotificationsService {

async processGrantUpdatedNotifications() {
console.log('Running Process Grant Updated Notifications...');
console.log('Running Process Grant Updated Notifications.. OLD ONE.');
const reference = `${
this.GRANT_UPDATED_TEMPLATE_ID
}-${new Date().toISOString()}`;
Expand Down
12 changes: 6 additions & 6 deletions src/notifications/v2/notifications.grant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class GrantNotificationsService {
}
};

async processGrantUpdatedNotifications() {
processGrantUpdatedNotifications = async () => {
console.log('Running Process Grant Updated Notifications...');

const grantIds = await this.grantService.findAllUpdatedGrants();
Expand Down Expand Up @@ -215,9 +215,9 @@ export class GrantNotificationsService {
'en-US': false,
},
});
}
};

async processGrantUpcomingNotifications() {
processGrantUpcomingNotifications = async () => {
console.log('Running Process Grant Upcoming Notifications...');
const grants = [
...(await this.grantService.findAllUpcomingClosingGrants()),
Expand Down Expand Up @@ -248,9 +248,9 @@ export class GrantNotificationsService {
);
}
}
}
};

async processNewGrantsNotifications() {
processNewGrantsNotifications = async () => {
console.log('Running Process New Grants Notifications...');

const last7days = DateTime.now().minus({ days: 7 }).startOf('day');
Expand All @@ -275,5 +275,5 @@ export class GrantNotificationsService {
await this.sendNewGrantsEmailsToBatch(batch, last7days);
}
}
}
};
}
31 changes: 6 additions & 25 deletions src/notifications/v2/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,19 @@ export class v2NotificationsService {
private schedularRegistry: SchedulerRegistry,
) {}

async processGrantUpdatedNotifications() {
return this.v2GrantService.processGrantUpdatedNotifications();
}

async processGrantUpcomingNotifications() {
return this.v2GrantService.processGrantUpcomingNotifications();
}

async processNewGrantsNotifications() {
return this.v2GrantService.processNewGrantsNotifications();
}

async processSavedSearchMatches() {
return this.v2SavedSearchService.processSavedSearchMatches();
}

async processSavedSearchMatchesNotifications() {
return this.v2SavedSearchService.processSavedSearchMatchesNotifications();
}

async processScheduledJob({ timer, type }: ScheduledJob, index: number) {
const CRON_JOB_MAP = {
[ScheduledJobType.GRANT_UPDATED]:
this.processGrantUpdatedNotifications.bind(this),
this.v2GrantService.processGrantUpdatedNotifications,
[ScheduledJobType.GRANT_UPCOMING]:
this.processGrantUpcomingNotifications.bind(this),
this.v2GrantService.processGrantUpcomingNotifications,
[ScheduledJobType.NEW_GRANTS]:
this.processNewGrantsNotifications.bind(this),
this.v2GrantService.processNewGrantsNotifications,
[ScheduledJobType.SAVED_SEARCH_MATCHES]:
this.processSavedSearchMatches.bind(this),
this.v2SavedSearchService.processSavedSearchMatches,
[ScheduledJobType.SAVED_SEARCH_MATCHES_NOTIFICATION]:
this.processSavedSearchMatchesNotifications.bind(this),
this.v2SavedSearchService
.processSavedSearchMatchesNotifications,
};
const cronFn = CRON_JOB_MAP[type as keyof typeof CRON_JOB_MAP];
const cronJob = getCronJob(cronFn, timer);
Expand Down

0 comments on commit 610c9da

Please sign in to comment.