Slice the popular emails to the top 20

This commit is contained in:
Ian Philips 2022-08-19 14:45:04 -06:00
parent 36bfbe8f42
commit 634196d8f1

View File

@ -43,13 +43,15 @@ async function sendTrendingMarketsEmailsToAllUsers() {
const privateUsersToSendEmailsTo = privateUsers.filter((user) => { const privateUsersToSendEmailsTo = privateUsers.filter((user) => {
return !user.unsubscribedFromWeeklyTrendingEmails return !user.unsubscribedFromWeeklyTrendingEmails
}) })
const trendingContracts = (await getTrendingContracts()).filter( const trendingContracts = (await getTrendingContracts())
(contract) => .filter(
!( (contract) =>
contract.question.toLowerCase().includes('trump') && !(
contract.question.toLowerCase().includes('president') contract.question.toLowerCase().includes('trump') &&
) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS contract.question.toLowerCase().includes('president')
) ) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS
)
.slice(0, 20)
for (const privateUser of privateUsersToSendEmailsTo) { for (const privateUser of privateUsersToSendEmailsTo) {
if (!privateUser.email) { if (!privateUser.email) {
log(`No email for ${privateUser.username}`) log(`No email for ${privateUser.username}`)