Skip to content

Commit

Permalink
Notifications service uses binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-tco committed Oct 24, 2023
1 parent 6063d74 commit 8809f80
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/notifications/v2/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,38 @@ export class v2NotificationsService {
private schedularRegistry: SchedulerRegistry,
) {}

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

0 comments on commit 8809f80

Please sign in to comment.