stats are averages now

This commit is contained in:
keyan 2023-05-19 18:12:48 -05:00
parent 2d0cf25b09
commit 4aee2c745f
2 changed files with 17 additions and 13 deletions

View File

@ -90,12 +90,12 @@ export default {
if (when !== 'day') {
return await models.$queryRaw(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'any', 'value', sum("any")),
json_build_object('name', 'jobs', 'value', sum(jobs)),
json_build_object('name', 'boost', 'value', sum(boost)),
json_build_object('name', 'fees', 'value', sum(fees)),
json_build_object('name', 'tips', 'value', sum(tips)),
json_build_object('name', 'donation', 'value', sum(donations))
json_build_object('name', 'any', 'value', floor(avg("any"))),
json_build_object('name', 'jobs', 'value', floor(avg(jobs))),
json_build_object('name', 'boost', 'value', floor(avg(boost))),
json_build_object('name', 'fees', 'value', floor(avg(fees))),
json_build_object('name', 'tips', 'value', floor(avg(tips))),
json_build_object('name', 'donation', 'value', floor(avg(donations)))
) AS data
FROM spender_growth_days
WHERE ${viewIntervalClause(when, 'spender_growth_days', false)}
@ -192,11 +192,11 @@ export default {
if (when !== 'day') {
return await models.$queryRaw(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'any', 'value', sum("any")),
json_build_object('name', 'posts', 'value', sum(posts)),
json_build_object('name', 'comments', 'value', sum(comments)),
json_build_object('name', 'rewards', 'value', sum(rewards)),
json_build_object('name', 'referrals', 'value', sum(referrals))
json_build_object('name', 'any', 'value', floor(avg("any"))),
json_build_object('name', 'posts', 'value', floor(avg(posts))),
json_build_object('name', 'comments', 'value', floor(floor(avg(comments)))),
json_build_object('name', 'rewards', 'value', floor(avg(rewards))),
json_build_object('name', 'referrals', 'value', floor(avg(referrals)))
) AS data
FROM stackers_growth_days
WHERE ${viewIntervalClause(when, 'stackers_growth_days', false)}

View File

@ -4,6 +4,7 @@ import Layout from '../../components/layout'
import { Col, Row } from 'react-bootstrap'
import { UsageHeader } from '../../components/usage-header'
import { WhenLineChart, WhenAreaChart } from '../../components/when-charts'
import { useRouter } from 'next/router'
export const getServerSideProps = getGetServerSideProps(
gql`
@ -56,12 +57,15 @@ export const getServerSideProps = getGetServerSideProps(
export default function Growth ({
data: { registrationGrowth, itemGrowth, spendingGrowth, spenderGrowth, stackingGrowth, stackerGrowth }
}) {
const router = useRouter()
const { when } = router.query
const avg = ['month', 'year', 'forever'].includes(when) ? 'avg daily' : ''
return (
<Layout>
<UsageHeader />
<Row>
<Col className='mt-3'>
<div className='text-center text-muted font-weight-bold'>stackers</div>
<div className='text-center text-muted font-weight-bold'>{avg} stackers</div>
<WhenLineChart data={stackerGrowth} />
</Col>
<Col className='mt-3'>
@ -71,7 +75,7 @@ export default function Growth ({
</Row>
<Row>
<Col className='mt-3'>
<div className='text-center text-muted font-weight-bold'>spenders</div>
<div className='text-center text-muted font-weight-bold'>{avg} spenders</div>
<WhenLineChart data={spenderGrowth} />
</Col>
<Col className='mt-3'>