Send study reminder emails 8 hours after lesson release
Lessons release at 1:00 AM, but reminders fired immediately, landing around 9 PM the prior evening. Delay sends by 8 hours so they go out at 9:00 AM on the release day.
This commit is contained in:
@@ -638,12 +638,14 @@ export async function scheduleStudyReminders(sendStudyReminderEmail) {
|
|||||||
const sectionId = section.id
|
const sectionId = section.id
|
||||||
const releaseDate = getSectionReleaseDate(section)
|
const releaseDate = getSectionReleaseDate(section)
|
||||||
if (!releaseDate) continue
|
if (!releaseDate) continue
|
||||||
if (releaseDate > now) continue
|
// Lessons release at 1:00 AM; reminder emails go out 8 hours later, at 9:00 AM the same day.
|
||||||
|
const sendDate = new Date(releaseDate.getTime() + 8 * 60 * 60 * 1000)
|
||||||
|
if (sendDate > now) continue
|
||||||
const sentForStudy = Array.isArray(userSent[studySlug]) ? userSent[studySlug] : []
|
const sentForStudy = Array.isArray(userSent[studySlug]) ? userSent[studySlug] : []
|
||||||
if (sentForStudy.includes(sectionId)) continue
|
if (sentForStudy.includes(sectionId)) continue
|
||||||
|
|
||||||
const hoursSinceRelease = (now.getTime() - releaseDate.getTime()) / (1000 * 60 * 60)
|
const hoursSinceSend = (now.getTime() - sendDate.getTime()) / (1000 * 60 * 60)
|
||||||
if (hoursSinceRelease > 24) continue
|
if (hoursSinceSend > 24) continue
|
||||||
|
|
||||||
const canonical = state.cachedSiteContent?.seo?.canonicalUrl || 'https://versebyversewithnate.us/'
|
const canonical = state.cachedSiteContent?.seo?.canonicalUrl || 'https://versebyversewithnate.us/'
|
||||||
const base = canonical.endsWith('/') ? canonical.slice(0, -1) : canonical
|
const base = canonical.endsWith('/') ? canonical.slice(0, -1) : canonical
|
||||||
|
|||||||
Reference in New Issue
Block a user