-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0210ece
commit 933d70d
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
libs/medic-users-meta/migrations/20240315.do.view_apdex_scores.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
CREATE VIEW view_apdex_scores AS | ||
WITH apdex_telemetry_data AS ( | ||
SELECT | ||
substring(metric from '^(.*):apdex:') AS event_category, | ||
CASE | ||
WHEN metric LIKE '%:satisfied' THEN 'satisfied' | ||
WHEN metric LIKE '%:tolerable' THEN 'tolerable' | ||
WHEN metric LIKE '%:frustrated' THEN 'frustrated' | ||
END AS event_type, | ||
SUM(count) AS event_count | ||
FROM | ||
useview_telemetry_metrics | ||
WHERE metric LIKE '%:apdex:%' | ||
GROUP BY event_category, event_type | ||
), | ||
apdex_scores AS ( | ||
SELECT | ||
event_category, | ||
SUM(CASE WHEN event_type = 'satisfied' THEN event_count ELSE 0 END) AS satisfied_count, | ||
SUM(CASE WHEN event_type = 'tolerable' THEN event_count ELSE 0 END) AS tolerable_count, | ||
SUM(CASE WHEN event_type = 'frustrated' THEN event_count ELSE 0 END) AS frustrated_count, | ||
SUM(event_count) AS total_event_count | ||
FROM apdex_telemetry_data | ||
GROUP BY event_category | ||
) | ||
SELECT | ||
event_category, | ||
satisfied_count, | ||
tolerable_count, | ||
frustrated_count, | ||
ROUND(((satisfied_count + (tolerable_count / 2.0)) / total_event_count)::numeric, 2) AS apdex_score | ||
FROM apdex_scores | ||
ORDER BY apdex_score asc; |