Skip to content

Commit

Permalink
Use 30d intervals for metrics page
Browse files Browse the repository at this point in the history
  • Loading branch information
N2D4 committed Jan 4, 2025
1 parent b3d1dfb commit ab26bc8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/backend/src/app/api/v1/internal/metrics/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function loadTotalUsers(projectId: string, now: Date): Promise<DataPoints>
return (await prismaClient.$queryRaw<{date: Date, dailyUsers: bigint, cumUsers: bigint}[]>`
WITH date_series AS (
SELECT GENERATE_SERIES(
${now}::date - INTERVAL '1 month',
${now}::date - INTERVAL '30 days',
${now}::date,
'1 day'
)
Expand All @@ -72,7 +72,7 @@ async function loadDailyActiveUsers(projectId: string, now: Date) {
const res = await prismaClient.$queryRaw<{day: Date, dau: bigint}[]>`
WITH date_series AS (
SELECT GENERATE_SERIES(
${now}::date - INTERVAL '1 month',
${now}::date - INTERVAL '30 days',
${now}::date,
'1 day'
)
Expand All @@ -83,7 +83,7 @@ async function loadDailyActiveUsers(projectId: string, now: Date) {
DATE_TRUNC('day', "eventStartedAt") AS "day",
COUNT(DISTINCT "data"->'userId') AS "dau"
FROM "Event"
WHERE "eventStartedAt" >= ${now} - INTERVAL '1 month'
WHERE "eventStartedAt" >= ${now} - INTERVAL '30 days'
AND "eventStartedAt" < ${now}
AND '$user-activity' = ANY("systemEventTypeIds"::text[])
AND "data"->>'projectId' = ${projectId}
Expand Down

0 comments on commit ab26bc8

Please sign in to comment.