stats are averages now
This commit is contained in:
parent
2d0cf25b09
commit
4aee2c745f
|
@ -90,12 +90,12 @@ export default {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRaw(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', sum("any")),
|
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
||||||
json_build_object('name', 'jobs', 'value', sum(jobs)),
|
json_build_object('name', 'jobs', 'value', floor(avg(jobs))),
|
||||||
json_build_object('name', 'boost', 'value', sum(boost)),
|
json_build_object('name', 'boost', 'value', floor(avg(boost))),
|
||||||
json_build_object('name', 'fees', 'value', sum(fees)),
|
json_build_object('name', 'fees', 'value', floor(avg(fees))),
|
||||||
json_build_object('name', 'tips', 'value', sum(tips)),
|
json_build_object('name', 'tips', 'value', floor(avg(tips))),
|
||||||
json_build_object('name', 'donation', 'value', sum(donations))
|
json_build_object('name', 'donation', 'value', floor(avg(donations)))
|
||||||
) AS data
|
) AS data
|
||||||
FROM spender_growth_days
|
FROM spender_growth_days
|
||||||
WHERE ${viewIntervalClause(when, 'spender_growth_days', false)}
|
WHERE ${viewIntervalClause(when, 'spender_growth_days', false)}
|
||||||
|
@ -192,11 +192,11 @@ export default {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRaw(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', sum("any")),
|
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
||||||
json_build_object('name', 'posts', 'value', sum(posts)),
|
json_build_object('name', 'posts', 'value', floor(avg(posts))),
|
||||||
json_build_object('name', 'comments', 'value', sum(comments)),
|
json_build_object('name', 'comments', 'value', floor(floor(avg(comments)))),
|
||||||
json_build_object('name', 'rewards', 'value', sum(rewards)),
|
json_build_object('name', 'rewards', 'value', floor(avg(rewards))),
|
||||||
json_build_object('name', 'referrals', 'value', sum(referrals))
|
json_build_object('name', 'referrals', 'value', floor(avg(referrals)))
|
||||||
) AS data
|
) AS data
|
||||||
FROM stackers_growth_days
|
FROM stackers_growth_days
|
||||||
WHERE ${viewIntervalClause(when, 'stackers_growth_days', false)}
|
WHERE ${viewIntervalClause(when, 'stackers_growth_days', false)}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Layout from '../../components/layout'
|
||||||
import { Col, Row } from 'react-bootstrap'
|
import { Col, Row } from 'react-bootstrap'
|
||||||
import { UsageHeader } from '../../components/usage-header'
|
import { UsageHeader } from '../../components/usage-header'
|
||||||
import { WhenLineChart, WhenAreaChart } from '../../components/when-charts'
|
import { WhenLineChart, WhenAreaChart } from '../../components/when-charts'
|
||||||
|
import { useRouter } from 'next/router'
|
||||||
|
|
||||||
export const getServerSideProps = getGetServerSideProps(
|
export const getServerSideProps = getGetServerSideProps(
|
||||||
gql`
|
gql`
|
||||||
|
@ -56,12 +57,15 @@ export const getServerSideProps = getGetServerSideProps(
|
||||||
export default function Growth ({
|
export default function Growth ({
|
||||||
data: { registrationGrowth, itemGrowth, spendingGrowth, spenderGrowth, stackingGrowth, stackerGrowth }
|
data: { registrationGrowth, itemGrowth, spendingGrowth, spenderGrowth, stackingGrowth, stackerGrowth }
|
||||||
}) {
|
}) {
|
||||||
|
const router = useRouter()
|
||||||
|
const { when } = router.query
|
||||||
|
const avg = ['month', 'year', 'forever'].includes(when) ? 'avg daily' : ''
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<UsageHeader />
|
<UsageHeader />
|
||||||
<Row>
|
<Row>
|
||||||
<Col className='mt-3'>
|
<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} />
|
<WhenLineChart data={stackerGrowth} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col className='mt-3'>
|
<Col className='mt-3'>
|
||||||
|
@ -71,7 +75,7 @@ export default function Growth ({
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col className='mt-3'>
|
<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} />
|
<WhenLineChart data={spenderGrowth} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col className='mt-3'>
|
<Col className='mt-3'>
|
||||||
|
|
Loading…
Reference in New Issue