From 1ef2f12601d0f8954d2f7491b4bca6bea7560c1f Mon Sep 17 00:00:00 2001 From: Riccardo Date: Sat, 29 Jun 2024 08:37:27 +0200 Subject: [PATCH] fix: extended time delta for mailing --- README.md | 2 +- app/api/mailing/route.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 46e5388..5adfc2a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Future improvements -- Cron every 10 minutes: people are more likely to open the newsletter if delivered around the time when they subscribed (if cron becomes not enough, then the cost of sending all the emails might be a bigger issue) +- Cron every 10 minutes and redure time delta to 10 minutes: people are more likely to open the newsletter if delivered around the time when they subscribed (if cron becomes not enough, then the cost of sending all the emails might be a bigger issue) ## Some resources used diff --git a/app/api/mailing/route.ts b/app/api/mailing/route.ts index 2c74872..0ebd155 100644 --- a/app/api/mailing/route.ts +++ b/app/api/mailing/route.ts @@ -12,7 +12,7 @@ import { NextRequest } from 'next/server'; import { Resend } from 'resend'; const ONE_DAY_IN_MS = 1000 * 60 * 60 * 24; -const TEN_MINUTES_IN_MS = 1000 * 10 * 60; +const DELTA_MINUTES_IN_MS = 1000 * 60 * 60; export async function GET(request: NextRequest) { if ( @@ -32,7 +32,7 @@ export async function GET(request: NextRequest) { OR: [ { lastMail: { - lt: new Date(Date.now() - ONE_DAY_IN_MS + TEN_MINUTES_IN_MS) // 24h - 10m + lt: new Date(Date.now() - ONE_DAY_IN_MS + DELTA_MINUTES_IN_MS) // 24h - 60m } }, {