From 1c73d2192587356e6c2010faee1fe8178daba3a1 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 23 Aug 2022 00:27:07 -0500 Subject: [PATCH] weeklyMarketsEmails: send different markets to different users --- functions/src/weekly-markets-emails.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/src/weekly-markets-emails.ts b/functions/src/weekly-markets-emails.ts index a20e40a2..bf839d00 100644 --- a/functions/src/weekly-markets-emails.ts +++ b/functions/src/weekly-markets-emails.ts @@ -92,9 +92,11 @@ async function sendTrendingMarketsEmailsToAllUsers() { } } +const fiveMinutes = 5 * 60 * 1000 +const seed = Math.round(Date.now() / fiveMinutes).toString() +const rng = createRNG(seed) + function chooseRandomSubset(contracts: Contract[], count: number) { - const fiveMinutes = 5 * 60 * 1000 - const seed = Math.round(Date.now() / fiveMinutes).toString() - shuffle(contracts, createRNG(seed)) + shuffle(contracts, rng) return contracts.slice(0, count) }