diff --git a/api/resolvers/growth.js b/api/resolvers/growth.js index 8dce1d72..be83c74c 100644 --- a/api/resolvers/growth.js +++ b/api/resolvers/growth.js @@ -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)} diff --git a/pages/users/[when].js b/pages/users/[when].js index 6a3db864..f2baf100 100644 --- a/pages/users/[when].js +++ b/pages/users/[when].js @@ -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 ( -
stackers
+
{avg} stackers
@@ -71,7 +75,7 @@ export default function Growth ({
-
spenders
+
{avg} spenders