diff --git a/src/scripts/send-emails-to-customers.ts b/src/scripts/send-emails-to-customers.ts index 05c4dda..9f859b3 100644 --- a/src/scripts/send-emails-to-customers.ts +++ b/src/scripts/send-emails-to-customers.ts @@ -167,7 +167,8 @@ async function main() { ) .where('contact.id IS NULL') .andWhere('customer.email IS NOT NULL') - .andWhere('customer.email != :emptyEmail', { emptyEmail: '' }); + .andWhere('customer.email != :emptyEmail', { emptyEmail: '' }) + .limit(100); } else { // Find customers with exactly N email contact records customersQuery = customersQuery @@ -180,7 +181,8 @@ async function main() { .where('customer.email IS NOT NULL') .andWhere('customer.email != :emptyEmail', { emptyEmail: '' }) .groupBy('customer.id') - .having('COUNT(contact.id) = :count', { count: emailCount }); + .having('COUNT(contact.id) = :count', { count: emailCount }) + .limit(100); } const filteredCustomers = await customersQuery.getMany();