Turn 9am into a constant

This commit is contained in:
Ian Philips 2022-08-18 16:57:55 -06:00
parent e7a033ff08
commit d1ba6d5240
3 changed files with 10 additions and 2 deletions

View File

@ -5,3 +5,4 @@ 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 = 1 export const BETTING_STREAK_BONUS_AMOUNT = 1
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_RESET_HOUR,
UNIQUE_BETTOR_BONUS_AMOUNT, UNIQUE_BETTOR_BONUS_AMOUNT,
} from '../../common/numeric-constants' } from '../../common/numeric-constants'
import { import {
@ -247,7 +248,12 @@ const notifyFills = async (
const getPreviousBettingStreakResetTime = () => { const getPreviousBettingStreakResetTime = () => {
const today = Date.now() const today = Date.now()
let betStreakResetTime = new Date().setUTCHours(9, 0, 0, 0) let betStreakResetTime = new Date().setUTCHours(
BETTING_STREAK_RESET_HOUR,
0,
0,
0
)
if (today < betStreakResetTime) { if (today < betStreakResetTime) {
betStreakResetTime = betStreakResetTime - DAY_MS betStreakResetTime = betStreakResetTime - DAY_MS
} }

View File

@ -4,10 +4,11 @@ import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin' import * as admin from 'firebase-admin'
import { User } from '../../common/user' import { User } from '../../common/user'
import { DAY_MS } from '../../common/util/time' import { DAY_MS } from '../../common/util/time'
import { BETTING_STREAK_RESET_HOUR } from '../../common/numeric-constants'
const firestore = admin.firestore() const firestore = admin.firestore()
export const resetBettingStreaksForUsers = functions.pubsub export const resetBettingStreaksForUsers = functions.pubsub
.schedule('0 9 * * *') .schedule(`0 ${BETTING_STREAK_RESET_HOUR} * * *`)
.onRun(async () => { .onRun(async () => {
await resetBettingStreaksInternal() await resetBettingStreaksInternal()
}) })