@@ -596,7 +596,7 @@ async function sendInterviewScheduleReminderNotifications () {
596
596
597
597
localLogger . debug ( '[sendInterviewScheduleReminderNotifications]: Looking for due records...' )
598
598
const currentTime = moment . utc ( )
599
- const compareTime = currentTime . add ( - INTERVIEW_REMINDER_DAY_AFTER ) . add ( 1 , 'days' ) . startOf ( 'day' )
599
+ const compareTime = currentTime . clone ( ) . subtract ( moment . duration ( INTERVIEW_REMINDER_DAY_AFTER ) ) . endOf ( 'day' )
600
600
601
601
const timestampFilter = {
602
602
[ Op . and ] : [
@@ -631,25 +631,28 @@ async function sendInterviewScheduleReminderNotifications () {
631
631
let interviewCount = 0
632
632
for ( const interview of interviews ) {
633
633
const start = moment ( interview . createdAt )
634
- if ( currentTime . subtract ( INTERVIEW_REMINDER_DAY_AFTER ) . diff ( start , 'days' ) % INTERVIEW_REMINDER_FREQUENCY === 0 ) {
635
- // sendEmail
636
- const data = await getDataForInterview ( interview )
637
- if ( ! data ) { continue }
638
-
639
- if ( ! _ . isEmpty ( data . guestEmail ) ) {
640
- // send guest emails
641
- sendNotification ( { } , {
642
- template,
643
- recipients : [ { email : data . guestEmail } ] ,
644
- data : {
645
- ...data ,
646
- subject : `Reminder: ${ data . duration } minutes tech interview with ${ data . guestFullName } for ${ data . jobTitle } is requested by the Customer`
647
- }
648
- } )
649
- } else {
650
- localLogger . error ( `Interview id: ${ interview . id } guest emails not present` , 'sendInterviewScheduleReminderNotifications' )
634
+ if ( currentTime . clone ( ) . subtract ( INTERVIEW_REMINDER_DAY_AFTER ) . diff ( start , 'days' ) % INTERVIEW_REMINDER_FREQUENCY === 0 ) {
635
+ const minutesInterval = currentTime . clone ( ) . diff ( start , 'minutes' ) % ( 60 * 24 )
636
+ if ( minutesInterval < moment . duration ( config . INTERVIEW_SCHEDULE_REMINDER_WINDOW ) . minutes ( ) ) {
637
+ // sendEmail
638
+ const data = await getDataForInterview ( interview )
639
+ if ( ! data ) { continue }
640
+
641
+ if ( ! _ . isEmpty ( data . guestEmail ) ) {
642
+ // send guest emails
643
+ sendNotification ( { } , {
644
+ template,
645
+ recipients : [ { email : data . guestEmail } ] ,
646
+ data : {
647
+ ...data ,
648
+ subject : `Reminder: ${ data . duration } minutes tech interview with ${ data . guestFullName } for ${ data . jobTitle } is requested by the Customer`
649
+ }
650
+ } )
651
+ } else {
652
+ localLogger . error ( `Interview id: ${ interview . id } guest emails not present` , 'sendInterviewScheduleReminderNotifications' )
653
+ }
654
+ interviewCount ++
651
655
}
652
- interviewCount ++
653
656
}
654
657
}
655
658
0 commit comments