From 82091fbd5d444581cb6c0bbd3eae387e1e76b55d Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 10 Sep 2024 17:25:38 +0200 Subject: [PATCH 1/3] Fix #1484: keep only one status per client and per source --- checks/remotesettings/uptake_error_rate.py | 13 +++++++++++-- telescope/utils.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/checks/remotesettings/uptake_error_rate.py b/checks/remotesettings/uptake_error_rate.py index a47afa1c..aba97fcd 100644 --- a/checks/remotesettings/uptake_error_rate.py +++ b/checks/remotesettings/uptake_error_rate.py @@ -32,6 +32,7 @@ WITH uptake_telemetry AS ( SELECT + client_id, timestamp AS submission_timestamp, normalized_channel, SPLIT(app_version, '.')[OFFSET(0)] AS version, @@ -47,6 +48,13 @@ AND event_string_value <> 'up_to_date' {version_condition} {channel_condition} +), +-- Enumerate all the statuses reported by a client for each source +row_number_by_client_id AS ( + SELECT + ROW_NUMBER() OVER (PARTITION BY client_id, source, status) AS rn, + * + FROM uptake_telemetry ) SELECT -- Min/Max timestamps of this period @@ -57,8 +65,9 @@ normalized_channel AS channel, version, COUNT(*) AS total -FROM uptake_telemetry -WHERE {source_condition} +FROM row_number_by_client_id +WHERE rn = 1 -- Keep only one status per client and per source + AND {source_condition} GROUP BY period, source, status, channel, version ORDER BY period, source """ diff --git a/telescope/utils.py b/telescope/utils.py index 0e1b1dc1..e0c1b447 100644 --- a/telescope/utils.py +++ b/telescope/utils.py @@ -400,7 +400,7 @@ async def fetch_bigquery(sql): # pragma: nocover """ Execute specified SQL and return rows. """ - + print(sql) def job(): bqclient = getattr(threadlocal, "bqclient", None) From 81a447c1fdc586e13768089a3c6a244aadd82e37 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 10 Sep 2024 17:32:11 +0200 Subject: [PATCH 2/3] Remove print() to debug SQL --- telescope/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/telescope/utils.py b/telescope/utils.py index e0c1b447..8faa3f81 100644 --- a/telescope/utils.py +++ b/telescope/utils.py @@ -400,7 +400,6 @@ async def fetch_bigquery(sql): # pragma: nocover """ Execute specified SQL and return rows. """ - print(sql) def job(): bqclient = getattr(threadlocal, "bqclient", None) From 53643a7e15684cc5c6d98d289e975b8f7f5b6298 Mon Sep 17 00:00:00 2001 From: Mathieu Leplatre Date: Tue, 10 Sep 2024 17:33:51 +0200 Subject: [PATCH 3/3] 'make format' --- telescope/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/telescope/utils.py b/telescope/utils.py index 8faa3f81..0e1b1dc1 100644 --- a/telescope/utils.py +++ b/telescope/utils.py @@ -400,6 +400,7 @@ async def fetch_bigquery(sql): # pragma: nocover """ Execute specified SQL and return rows. """ + def job(): bqclient = getattr(threadlocal, "bqclient", None)