From 36bfbe8f4240714fc023c7980f39ff1628a1712a Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Fri, 19 Aug 2022 14:37:16 -0600 Subject: [PATCH] Change betting streak modal, tweak trending email query --- common/numeric-constants.ts | 1 + functions/src/on-create-bet.ts | 3 ++- functions/src/weekly-markets-emails.ts | 9 +++++---- web/components/profile/betting-streak-modal.tsx | 10 ++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/common/numeric-constants.ts b/common/numeric-constants.ts index 9d41d54f..4d04a2c7 100644 --- a/common/numeric-constants.ts +++ b/common/numeric-constants.ts @@ -5,4 +5,5 @@ export const NUMERIC_GRAPH_COLOR = '#5fa5f9' export const NUMERIC_TEXT_COLOR = 'text-blue-500' export const UNIQUE_BETTOR_BONUS_AMOUNT = 10 export const BETTING_STREAK_BONUS_AMOUNT = 5 +export const BETTING_STREAK_BONUS_MAX = 100 export const BETTING_STREAK_RESET_HOUR = 9 diff --git a/functions/src/on-create-bet.ts b/functions/src/on-create-bet.ts index c5648293..45adade5 100644 --- a/functions/src/on-create-bet.ts +++ b/functions/src/on-create-bet.ts @@ -14,6 +14,7 @@ import { Contract } from '../../common/contract' import { runTxn, TxnData } from './transact' import { BETTING_STREAK_BONUS_AMOUNT, + BETTING_STREAK_BONUS_MAX, BETTING_STREAK_RESET_HOUR, UNIQUE_BETTOR_BONUS_AMOUNT, } from '../../common/numeric-constants' @@ -86,7 +87,7 @@ const updateBettingStreak = async ( // Send them the bonus times their streak const bonusAmount = Math.min( BETTING_STREAK_BONUS_AMOUNT * newBettingStreak, - 100 + BETTING_STREAK_BONUS_MAX ) const fromUserId = isProd() ? HOUSE_LIQUIDITY_PROVIDER_ID diff --git a/functions/src/weekly-markets-emails.ts b/functions/src/weekly-markets-emails.ts index c5805d0b..62a06a7f 100644 --- a/functions/src/weekly-markets-emails.ts +++ b/functions/src/weekly-markets-emails.ts @@ -22,11 +22,12 @@ export async function getTrendingContracts() { firestore .collection('contracts') .where('isResolved', '==', false) - .where('closeTime', '>', Date.now() + DAY_MS) .where('visibility', '==', 'public') - .orderBy('closeTime', 'asc') + // can't use multiple inequality (/orderBy) operators on different fields, + // so have to filter for closed contracts separately .orderBy('popularityScore', 'desc') - .limit(15) + // might as well go big and do a quick filter for closed ones later + .limit(500) ) } @@ -47,7 +48,7 @@ async function sendTrendingMarketsEmailsToAllUsers() { !( contract.question.toLowerCase().includes('trump') && contract.question.toLowerCase().includes('president') - ) + ) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS ) for (const privateUser of privateUsersToSendEmailsTo) { if (!privateUser.email) { diff --git a/web/components/profile/betting-streak-modal.tsx b/web/components/profile/betting-streak-modal.tsx index 345d38b1..8404b89b 100644 --- a/web/components/profile/betting-streak-modal.tsx +++ b/web/components/profile/betting-streak-modal.tsx @@ -1,5 +1,10 @@ import { Modal } from 'web/components/layout/modal' import { Col } from 'web/components/layout/col' +import { + BETTING_STREAK_BONUS_AMOUNT, + BETTING_STREAK_BONUS_MAX, +} from 'common/numeric-constants' +import { formatMoney } from 'common/util/format' export function BettingStreakModal(props: { isOpen: boolean @@ -15,8 +20,9 @@ export function BettingStreakModal(props: { • What are they? - You get a reward for every consecutive day that you place a bet. The - more days you bet in a row, the more you earn! + You get {formatMoney(BETTING_STREAK_BONUS_AMOUNT)} more for each day + of consecutive betting up to {formatMoney(BETTING_STREAK_BONUS_MAX)} + . The more days you bet in a row, the more you earn! • Where can I check my streak?