Fix type error

This commit is contained in:
James Grugett 2022-10-10 13:01:13 -05:00
parent 4d038b43ad
commit ead8d17bf6
2 changed files with 9 additions and 14 deletions

View File

@ -1,13 +1,4 @@
import {
Dictionary,
groupBy,
keyBy,
last,
sortBy,
sum,
sumBy,
uniq,
} from 'lodash'
import { Dictionary, groupBy, last, sortBy, sum, sumBy, uniq } from 'lodash'
import { calculatePayout, getContractBetMetrics } from './calculate'
import { Bet, LimitBet } from './bet'
import {
@ -275,9 +266,13 @@ export const calculateMetricsByContract = (
let periodMetrics
if (c.mechanism === 'cpmm-1' && c.outcomeType === 'BINARY') {
periodMetrics = keyBy(['day', 'week', 'month'] as const, (period) => {
return calculatePeriodProfit(c, bets, period)
})
const periods = ['day', 'week', 'month'] as const
periodMetrics = Object.fromEntries(
periods.map((period) => [
period,
calculatePeriodProfit(c, bets, period),
])
)
}
return {

View File

@ -24,7 +24,7 @@ import { Group } from '../../common/group'
import { batchedWaitAll } from '../../common/util/promise'
import { newEndpointNoAuth } from './api'
import { getFunctionUrl } from '../../common/api'
import { filterDefined } from 'common/util/array'
import { filterDefined } from '../../common/util/array'
const firestore = admin.firestore()
export const scheduleUpdateMetrics = functions.pubsub