diff --git a/src/constants.ts b/src/constants.ts index 1a6e1c088f..1d87cc1fd1 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -46,3 +46,5 @@ export const CONST_SETTINGS_TAB_SLUGS = [ "notifications", "manage-account", ] as const; + +export const MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE = 5; diff --git a/src/scripts/cronjobs/monthlyActivityFree.tsx b/src/scripts/cronjobs/monthlyActivityFree.tsx index d682c49106..9439dbce2b 100644 --- a/src/scripts/cronjobs/monthlyActivityFree.tsx +++ b/src/scripts/cronjobs/monthlyActivityFree.tsx @@ -19,20 +19,13 @@ import createDbConnection from "../../db/connect"; import { logger } from "../../app/functions/server/logging"; import { getMonthlyActivityFreeUnsubscribeLink } from "../../app/functions/cronjobs/unsubscribeLinks"; import { hasPremium } from "../../app/functions/universal/user"; +import { MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE } from "../../constants"; await run(); await createDbConnection().destroy(); async function run() { - const batchSize = Number.parseInt( - process.env.MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE ?? "10", - 10, - ); - if (Number.isNaN(batchSize)) { - throw new Error( - `Could not send monthly activity emails, because the env var MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE has a non-numeric value: [${process.env.MONTHLY_ACTIVITY_EMAIL_BATCH_SIZE}].`, - ); - } + const batchSize = MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE; logger.info(`Getting free subscribers with batch size: ${batchSize}`); const subscribersToEmail = (await getFreeSubscribersWaitingForMonthlyEmail())