From 634196d8f1e7f7ab069e5dc1469b6b9e2fc20fb3 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 19 Aug 2022 14:45:04 -0600 Subject: [PATCH] Slice the popular emails to the top 20 --- functions/src/weekly-markets-emails.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/functions/src/weekly-markets-emails.ts b/functions/src/weekly-markets-emails.ts index 62a06a7f..c75d6617 100644 --- a/functions/src/weekly-markets-emails.ts +++ b/functions/src/weekly-markets-emails.ts @@ -43,13 +43,15 @@ async function sendTrendingMarketsEmailsToAllUsers() { const privateUsersToSendEmailsTo = privateUsers.filter((user) => { return !user.unsubscribedFromWeeklyTrendingEmails }) - const trendingContracts = (await getTrendingContracts()).filter( - (contract) => - !( - contract.question.toLowerCase().includes('trump') && - contract.question.toLowerCase().includes('president') - ) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS - ) + const trendingContracts = (await getTrendingContracts()) + .filter( + (contract) => + !( + contract.question.toLowerCase().includes('trump') && + contract.question.toLowerCase().includes('president') + ) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS + ) + .slice(0, 20) for (const privateUser of privateUsersToSendEmailsTo) { if (!privateUser.email) { log(`No email for ${privateUser.username}`)