Skip to content

Commit

Permalink
Fix query workspace usage (#5258)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored May 24, 2024
1 parent 0dbf8c5 commit a3815e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions front/pages/api/w/[wId]/workspace-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ async function getAnalytics(
growth_calculations AS (
SELECT
COALESCE(MAX(CASE WHEN period = 'last_7_days' THEN active_users END), 0) AS "last_7_days_active_users",
COALESCE(MAX(CASE WHEN period = 'last_30_days' THEN active_users END), 0) AS "last_30_days_active_users",
(COALESCE(MAX(CASE WHEN period = 'last_7_days' THEN active_users END), 0) - COALESCE(MAX(CASE WHEN period = 'previous_7_days' THEN active_users END), 0))::FLOAT
COALESCE(MAX(CASE WHEN period IN ('last_30_days', 'last_7_days', 'previous_7_days') THEN active_users END), 0) AS "last_30_days_active_users",
(COALESCE(MAX(CASE WHEN period = 'last_7_days' THEN active_users END), 0) - COALESCE(MAX(CASE WHEN period = 'previous_7_days' THEN active_users END), 0))::FLOAT
/ GREATEST(COALESCE(MAX(CASE WHEN period = 'previous_7_days' THEN active_users END), 1), 1) * 100 AS "wow_growth_pct",
(COALESCE(MAX(CASE WHEN period = 'last_30_days' THEN active_users END), 0) - COALESCE(MAX(CASE WHEN period = 'previous_30_days' THEN active_users END), 0))::FLOAT
(COALESCE(MAX(CASE WHEN period IN ('last_30_days', 'last_7_days', 'previous_7_days') THEN active_users END), 0) - COALESCE(MAX(CASE WHEN period = 'previous_30_days' THEN active_users END), 0))::FLOAT
/ GREATEST(COALESCE(MAX(CASE WHEN period = 'previous_30_days' THEN active_users END), 1), 1) * 100 AS "mom_growth_pct"
FROM aggregated_counts
)
Expand Down

0 comments on commit a3815e8

Please sign in to comment.