fix(dashboard): speed up project cards on project list
This commit is contained in:
@@ -52,20 +52,19 @@ function ProjectCard({ id, domain, name, organizationId }: IServiceProject) {
|
|||||||
|
|
||||||
async function ProjectChart({ id }: { id: string }) {
|
async function ProjectChart({ id }: { id: string }) {
|
||||||
const chart = await chQuery<{ value: number; date: string }>(
|
const chart = await chQuery<{ value: number; date: string }>(
|
||||||
`SELECT
|
`SELECT
|
||||||
countDistinct(profile_id) as value,
|
uniqHLL12(profile_id) as value,
|
||||||
toStartOfDay(created_at) as date
|
toStartOfDay(created_at) as date
|
||||||
FROM ${TABLE_NAMES.sessions}
|
FROM ${TABLE_NAMES.sessions}
|
||||||
WHERE
|
WHERE
|
||||||
sign = 1
|
sign = 1 AND
|
||||||
AND project_id = ${escape(id)}
|
project_id = ${escape(id)} AND
|
||||||
AND created_at >= now() - interval '1 month'
|
created_at >= now() - interval '1 month'
|
||||||
GROUP BY date
|
GROUP BY date
|
||||||
ORDER BY date ASC
|
ORDER BY date ASC
|
||||||
WITH FILL
|
WITH FILL FROM toStartOfDay(now() - interval '1 month')
|
||||||
FROM toStartOfDay(now() - interval '1 month')
|
TO toStartOfDay(now())
|
||||||
TO toStartOfDay(now())
|
STEP INTERVAL 1 day
|
||||||
STEP INTERVAL 1 day
|
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -93,15 +92,13 @@ async function ProjectMetrics({ id }: { id: string }) {
|
|||||||
}>(
|
}>(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
(
|
uniqHLL12(if(created_at >= (now() - toIntervalMonth(6)), profile_id, null)) AS months_3,
|
||||||
SELECT uniq(DISTINCT profile_id) as count FROM ${TABLE_NAMES.sessions} WHERE project_id = ${escape(id)} AND created_at >= now() - interval '6 months'
|
uniqHLL12(if(created_at >= (now() - toIntervalMonth(1)), profile_id, null)) AS month,
|
||||||
) as months_3,
|
uniqHLL12(if(created_at >= (now() - toIntervalDay(1)), profile_id, null)) AS day
|
||||||
(
|
FROM sessions
|
||||||
SELECT uniq(DISTINCT profile_id) as count FROM ${TABLE_NAMES.sessions} WHERE project_id = ${escape(id)} AND created_at >= now() - interval '1 month'
|
WHERE
|
||||||
) as month,
|
project_id = ${escape(id)} AND
|
||||||
(
|
created_at >= (now() - toIntervalMonth(6))
|
||||||
SELECT uniq(DISTINCT profile_id) as count FROM ${TABLE_NAMES.sessions} WHERE project_id = ${escape(id)} AND created_at >= now() - interval '1 day'
|
|
||||||
) as day
|
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user