Skip to content

Commit

Permalink
Merge branch 'main' into mntor-3840-1
Browse files Browse the repository at this point in the history
  • Loading branch information
codemist authored Dec 11, 2024
2 parents 59b4eb3 + 2a3ab7f commit c00b868
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/scripts/cronjobs/monthlyActivityFree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ async function run() {
`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}].`,
);
}

logger.info(`Getting free subscribers with batch size: ${batchSize}`);
const subscribersToEmail = (await getFreeSubscribersWaitingForMonthlyEmail())
.filter((subscriber) => {
const assumedCountryCode = getSignupLocaleCountry(subscriber);
Expand All @@ -41,11 +43,19 @@ async function run() {
.slice(0, batchSize);
await initEmail();

await Promise.allSettled(
subscribersToEmail.map((subscriber) =>
sendMonthlyActivityEmail(subscriber),
),
);
for (const subscriber of subscribersToEmail) {
try {
await sendMonthlyActivityEmail(subscriber);
logger.info("send_monthly_activity_email_free_success", {
subscriberId: subscriber.id,
});
} catch (error) {
logger.error("send_monthly_activity_email_free_error", {
subscriberId: subscriber.id,
error,
});
}
}

closeEmailPool();
console.log(
Expand Down

0 comments on commit c00b868

Please sign in to comment.