fixes/enhancements to users dashboard
This commit is contained in:
parent
6dd3bd9ed3
commit
4c7a6e4998
|
@ -4,7 +4,7 @@ export default {
|
|||
Query: {
|
||||
registrationGrowth: async (parent, args, { models }) => {
|
||||
return await models.$queryRaw(
|
||||
`SELECT date_trunc('month', created_at) AS time, count(*) as num
|
||||
`SELECT date_trunc('month', created_at) AS time, count("inviteId") as invited, count(*) - count("inviteId") as organic
|
||||
FROM users
|
||||
WHERE id > ${PLACEHOLDERS_NUM} AND date_trunc('month', now_utc()) <> date_trunc('month', created_at)
|
||||
GROUP BY time
|
||||
|
@ -60,7 +60,7 @@ export default {
|
|||
},
|
||||
stackedGrowth: async (parent, args, { models }) => {
|
||||
return await models.$queryRaw(
|
||||
`SELECT time, sum(airdrop) as airdrops, sum(post) as posts, sum(comment) as comments
|
||||
`SELECT time, sum(airdrop) as rewards, sum(post) as posts, sum(comment) as comments
|
||||
FROM
|
||||
((SELECT date_trunc('month', "ItemAct".created_at) AS time, 0 as airdrop,
|
||||
CASE WHEN "Item"."parentId" IS NULL THEN 0 ELSE sats END as comment,
|
||||
|
@ -134,7 +134,7 @@ export default {
|
|||
stackedWeekly: async (parent, args, { models }) => {
|
||||
const [stats] = await models.$queryRaw(
|
||||
`SELECT json_build_array(
|
||||
json_build_object('name', 'airdrops', 'value', sum(airdrop)),
|
||||
json_build_object('name', 'rewards', 'value', sum(airdrop)),
|
||||
json_build_object('name', 'posts', 'value', sum(post)),
|
||||
json_build_object('name', 'comments', 'value', sum(comment))
|
||||
) as array
|
||||
|
|
|
@ -2,7 +2,7 @@ import { gql } from 'apollo-server-micro'
|
|||
|
||||
export default gql`
|
||||
extend type Query {
|
||||
registrationGrowth: [TimeNum!]!
|
||||
registrationGrowth: [RegistrationGrowth!]!
|
||||
activeGrowth: [TimeNum!]!
|
||||
itemGrowth: [ItemGrowth!]!
|
||||
spentGrowth: [SpentGrowth!]!
|
||||
|
@ -27,6 +27,12 @@ export default gql`
|
|||
value: Int!
|
||||
}
|
||||
|
||||
type RegistrationGrowth {
|
||||
time: String!
|
||||
invited: Int!
|
||||
organic: Int!
|
||||
}
|
||||
|
||||
type ItemGrowth {
|
||||
time: String!
|
||||
jobs: Int!
|
||||
|
@ -36,7 +42,7 @@ export default gql`
|
|||
|
||||
type StackedGrowth {
|
||||
time: String!
|
||||
airdrops: Int!
|
||||
rewards: Int!
|
||||
posts: Int!
|
||||
comments: Int!
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ export const getServerSideProps = getGetServerSideProps(
|
|||
{
|
||||
registrationGrowth {
|
||||
time
|
||||
num
|
||||
invited
|
||||
organic
|
||||
}
|
||||
activeGrowth {
|
||||
time
|
||||
|
@ -34,7 +35,7 @@ export const getServerSideProps = getGetServerSideProps(
|
|||
time
|
||||
posts
|
||||
comments
|
||||
airdrops
|
||||
rewards
|
||||
}
|
||||
earnerGrowth {
|
||||
time
|
||||
|
@ -44,7 +45,7 @@ export const getServerSideProps = getGetServerSideProps(
|
|||
|
||||
const dateFormatter = timeStr => {
|
||||
const date = new Date(timeStr)
|
||||
return `${('0' + (date.getMonth() + 2)).slice(-2)}/${String(date.getFullYear()).slice(-2)}`
|
||||
return `${('0' + (date.getUTCMonth() % 12 + 1)).slice(-2)}/${String(date.getUTCFullYear()).slice(-2)}`
|
||||
}
|
||||
|
||||
export default function Growth ({
|
||||
|
@ -55,8 +56,8 @@ export default function Growth ({
|
|||
<UsageHeader />
|
||||
<Row>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold invisible'>earning users</div>
|
||||
<GrowthLineChart data={earnerGrowth} xName='month' yName='earning users' />
|
||||
<div className='text-center text-muted font-weight-bold invisible'>stackers</div>
|
||||
<GrowthLineChart data={earnerGrowth} xName='month' yName='stackers' />
|
||||
</Col>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold'>stacking</div>
|
||||
|
@ -75,12 +76,12 @@ export default function Growth ({
|
|||
</Row>
|
||||
<Row>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold invisible'>registrations</div>
|
||||
<GrowthLineChart data={registrationGrowth} xName='month' yName='registrations' />
|
||||
<div className='text-center text-muted font-weight-bold'>registrations</div>
|
||||
<GrowthAreaChart data={registrationGrowth} xName='month' yName='registrations' />
|
||||
</Col>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold invisible'>active users</div>
|
||||
<GrowthLineChart data={activeGrowth} xName='month' yName='interactive users' />
|
||||
<div className='text-center text-muted font-weight-bold invisible'>spenders</div>
|
||||
<GrowthLineChart data={activeGrowth} xName='month' yName='spenders' />
|
||||
</Col>
|
||||
</Row>
|
||||
</Layout>
|
||||
|
|
|
@ -40,11 +40,11 @@ export default function Growth ({
|
|||
<h3 className='text-center'>{registrationsWeekly}</h3>
|
||||
</Col>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold'>interactive users</div>
|
||||
<div className='text-center text-muted font-weight-bold'>spenders</div>
|
||||
<h3 className='text-center'>{activeWeekly}</h3>
|
||||
</Col>
|
||||
<Col className='mt-3'>
|
||||
<div className='text-center text-muted font-weight-bold'>earners</div>
|
||||
<div className='text-center text-muted font-weight-bold'>stackers</div>
|
||||
<h3 className='text-center'>{earnersWeekly}</h3>
|
||||
</Col>
|
||||
</Row>
|
||||
|
|
Loading…
Reference in New Issue