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