fix: extended time delta for mailing
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Future improvements
|
## 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
|
## Some resources used
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { NextRequest } from 'next/server';
|
|||||||
import { Resend } from 'resend';
|
import { Resend } from 'resend';
|
||||||
|
|
||||||
const ONE_DAY_IN_MS = 1000 * 60 * 60 * 24;
|
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) {
|
export async function GET(request: NextRequest) {
|
||||||
if (
|
if (
|
||||||
@@ -32,7 +32,7 @@ export async function GET(request: NextRequest) {
|
|||||||
OR: [
|
OR: [
|
||||||
{
|
{
|
||||||
lastMail: {
|
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
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user