import dayjs from 'dayjs'
import _ from 'lodash'
import { DailyCountChart } from '../components/analytics/charts'
import { Col } from '../components/layout/col'
import { Page } from '../components/page'
import { Title } from '../components/title'
import { getDailyBets } from '../lib/firebase/bets'
import { getDailyContracts } from '../lib/firebase/contracts'
export async function getStaticProps() {
const numberOfDays = 80
const today = dayjs(dayjs().format('YYYY-MM-DD'))
const startDate = today.subtract(numberOfDays, 'day')
const dailyBets = await getDailyBets(startDate.valueOf(), numberOfDays)
const dailyBetCounts = dailyBets.map((bets) => bets.length)
const dailyContracts = await getDailyContracts(
startDate.valueOf(),
numberOfDays
)
const dailyContractCounts = dailyContracts.map(
(contracts) => contracts.length
)
return {
props: {
startDate: startDate.valueOf(),
dailyBetCounts,
dailyContractCounts,
},
revalidate: 12 * 60 * 60, // regenerate after half a day
}
}
export default function Analytics(props: {
startDate: number
dailyBetCounts: number[]
dailyContractCounts: number[]
}) {
return (