Skip to content

Commit 70b2f76

Browse files
authored
Fix #1484: keep only one status per client per source and per period (#1487)
* Fix #1484: keep only one status per client and per source * Remove print() to debug SQL * 'make format'
1 parent 60971c2 commit 70b2f76

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

checks/remotesettings/uptake_error_rate.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
3333
WITH uptake_telemetry AS (
3434
SELECT
35+
client_id,
3536
timestamp AS submission_timestamp,
3637
normalized_channel,
3738
SPLIT(app_version, '.')[OFFSET(0)] AS version,
@@ -47,6 +48,13 @@
4748
AND event_string_value <> 'up_to_date'
4849
{version_condition}
4950
{channel_condition}
51+
),
52+
-- Enumerate all the statuses reported by a client for each source
53+
row_number_by_client_id AS (
54+
SELECT
55+
ROW_NUMBER() OVER (PARTITION BY client_id, source, status) AS rn,
56+
*
57+
FROM uptake_telemetry
5058
)
5159
SELECT
5260
-- Min/Max timestamps of this period
@@ -57,8 +65,9 @@
5765
normalized_channel AS channel,
5866
version,
5967
COUNT(*) AS total
60-
FROM uptake_telemetry
61-
WHERE {source_condition}
68+
FROM row_number_by_client_id
69+
WHERE rn = 1 -- Keep only one status per client and per source
70+
AND {source_condition}
6271
GROUP BY period, source, status, channel, version
6372
ORDER BY period, source
6473
"""

0 commit comments

Comments
 (0)