monthly earning users
This commit is contained in:
parent
f024cd39a2
commit
2c749dd07f
@ -33,6 +33,21 @@ export default {
|
|||||||
WHERE date_trunc('month', now_utc()) <> date_trunc('month', created_at)
|
WHERE date_trunc('month', now_utc()) <> date_trunc('month', created_at)
|
||||||
GROUP BY time
|
GROUP BY time
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
|
},
|
||||||
|
earnedGrowth: async (parent, args, { models }) => {
|
||||||
|
return await models.$queryRaw(
|
||||||
|
`SELECT time, count(distinct user_id) as num
|
||||||
|
FROM
|
||||||
|
((SELECT date_trunc('month', "ItemAct".created_at) AS time, "Item"."userId" as user_id
|
||||||
|
FROM "ItemAct"
|
||||||
|
JOIN "Item" on "ItemAct"."itemId" = "Item".id AND "Item"."userId" <> "ItemAct"."userId"
|
||||||
|
WHERE date_trunc('month', now_utc()) <> date_trunc('month', "ItemAct".created_at))
|
||||||
|
UNION ALL
|
||||||
|
(SELECT date_trunc('month', created_at) AS time, "userId" as user_id
|
||||||
|
FROM "Earn"
|
||||||
|
WHERE date_trunc('month', now_utc()) <> date_trunc('month', created_at))) u
|
||||||
|
GROUP BY time
|
||||||
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ export default gql`
|
|||||||
activeGrowth: [TimeNum!]!
|
activeGrowth: [TimeNum!]!
|
||||||
itemGrowth: [TimeNum!]!
|
itemGrowth: [TimeNum!]!
|
||||||
spentGrowth: [TimeNum!]!
|
spentGrowth: [TimeNum!]!
|
||||||
|
earnedGrowth: [TimeNum!]!
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeNum {
|
type TimeNum {
|
||||||
|
@ -24,14 +24,20 @@ export const getServerSideProps = getGetServerSideProps(
|
|||||||
time
|
time
|
||||||
num
|
num
|
||||||
}
|
}
|
||||||
|
earnedGrowth {
|
||||||
|
time
|
||||||
|
num
|
||||||
|
}
|
||||||
}`)
|
}`)
|
||||||
|
|
||||||
const dateFormatter = timeStr => {
|
const dateFormatter = timeStr => {
|
||||||
const date = new Date(timeStr)
|
const date = new Date(timeStr)
|
||||||
return `${('0' + (date.getMonth() + 1)).slice(-2)}/${String(date.getFullYear()).slice(-2)}`
|
return `${('0' + (date.getMonth() + 2)).slice(-2)}/${String(date.getFullYear()).slice(-2)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Growth ({ data: { registrationGrowth, activeGrowth, itemGrowth, spentGrowth } }) {
|
export default function Growth ({
|
||||||
|
data: { registrationGrowth, activeGrowth, itemGrowth, spentGrowth, earnedGrowth }
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Row className='mt-3'>
|
<Row className='mt-3'>
|
||||||
@ -50,6 +56,12 @@ export default function Growth ({ data: { registrationGrowth, activeGrowth, item
|
|||||||
<GrowthLineChart data={spentGrowth} xName='month' yName='sats spent' />
|
<GrowthLineChart data={spentGrowth} xName='month' yName='sats spent' />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row className='mt-3'>
|
||||||
|
<Col>
|
||||||
|
<GrowthLineChart data={earnedGrowth} xName='month' yName='earning users' />
|
||||||
|
</Col>
|
||||||
|
<Col />
|
||||||
|
</Row>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user