Skip to content

Commit

Permalink
Merge pull request #5429 from mozilla/MNTOR-3857
Browse files Browse the repository at this point in the history
MNTOR-3857: hardcode batch size
  • Loading branch information
mansaj authored Dec 18, 2024
2 parents c54e991 + b5982f2 commit 0b7c3dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ export const CONST_SETTINGS_TAB_SLUGS = [
"notifications",
"manage-account",
] as const;

export const MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE = 5;
11 changes: 2 additions & 9 deletions src/scripts/cronjobs/monthlyActivityFree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 0b7c3dd

Please sign in to comment.