Change betting streak modal, tweak trending email query

This commit is contained in:
Ian Philips 2022-08-19 14:37:16 -06:00
parent a0f62ba172
commit 36bfbe8f42
4 changed files with 16 additions and 7 deletions

View File

@ -5,4 +5,5 @@ export const NUMERIC_GRAPH_COLOR = '#5fa5f9'
export const NUMERIC_TEXT_COLOR = 'text-blue-500' export const NUMERIC_TEXT_COLOR = 'text-blue-500'
export const UNIQUE_BETTOR_BONUS_AMOUNT = 10 export const UNIQUE_BETTOR_BONUS_AMOUNT = 10
export const BETTING_STREAK_BONUS_AMOUNT = 5 export const BETTING_STREAK_BONUS_AMOUNT = 5
export const BETTING_STREAK_BONUS_MAX = 100
export const BETTING_STREAK_RESET_HOUR = 9 export const BETTING_STREAK_RESET_HOUR = 9

View File

@ -14,6 +14,7 @@ import { Contract } from '../../common/contract'
import { runTxn, TxnData } from './transact' import { runTxn, TxnData } from './transact'
import { import {
BETTING_STREAK_BONUS_AMOUNT, BETTING_STREAK_BONUS_AMOUNT,
BETTING_STREAK_BONUS_MAX,
BETTING_STREAK_RESET_HOUR, BETTING_STREAK_RESET_HOUR,
UNIQUE_BETTOR_BONUS_AMOUNT, UNIQUE_BETTOR_BONUS_AMOUNT,
} from '../../common/numeric-constants' } from '../../common/numeric-constants'
@ -86,7 +87,7 @@ const updateBettingStreak = async (
// Send them the bonus times their streak // Send them the bonus times their streak
const bonusAmount = Math.min( const bonusAmount = Math.min(
BETTING_STREAK_BONUS_AMOUNT * newBettingStreak, BETTING_STREAK_BONUS_AMOUNT * newBettingStreak,
100 BETTING_STREAK_BONUS_MAX
) )
const fromUserId = isProd() const fromUserId = isProd()
? HOUSE_LIQUIDITY_PROVIDER_ID ? HOUSE_LIQUIDITY_PROVIDER_ID

View File

@ -22,11 +22,12 @@ export async function getTrendingContracts() {
firestore firestore
.collection('contracts') .collection('contracts')
.where('isResolved', '==', false) .where('isResolved', '==', false)
.where('closeTime', '>', Date.now() + DAY_MS)
.where('visibility', '==', 'public') .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') .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('trump') &&
contract.question.toLowerCase().includes('president') contract.question.toLowerCase().includes('president')
) ) && (contract?.closeTime ?? 0) > Date.now() + DAY_MS
) )
for (const privateUser of privateUsersToSendEmailsTo) { for (const privateUser of privateUsersToSendEmailsTo) {
if (!privateUser.email) { if (!privateUser.email) {

View File

@ -1,5 +1,10 @@
import { Modal } from 'web/components/layout/modal' import { Modal } from 'web/components/layout/modal'
import { Col } from 'web/components/layout/col' 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: { export function BettingStreakModal(props: {
isOpen: boolean isOpen: boolean
@ -15,8 +20,9 @@ export function BettingStreakModal(props: {
<Col className={'gap-2'}> <Col className={'gap-2'}>
<span className={'text-indigo-700'}> What are they?</span> <span className={'text-indigo-700'}> What are they?</span>
<span className={'ml-2'}> <span className={'ml-2'}>
You get a reward for every consecutive day that you place a bet. The You get {formatMoney(BETTING_STREAK_BONUS_AMOUNT)} more for each day
more days you bet in a row, the more you earn! of consecutive betting up to {formatMoney(BETTING_STREAK_BONUS_MAX)}
. The more days you bet in a row, the more you earn!
</span> </span>
<span className={'text-indigo-700'}> <span className={'text-indigo-700'}>
Where can I check my streak? Where can I check my streak?