From 9d92352f1b9610eee68cc52bc7910f75ee25dfd6 Mon Sep 17 00:00:00 2001 From: Ioannis Foukarakis Date: Tue, 12 Nov 2024 14:23:32 +0200 Subject: [PATCH] Hotfix: use latest received_at (#1665) --- .../active_users/int_user_active_days_legacy_telemetry.sql | 5 +++-- .../active_users/int_user_active_days_mobile_telemetry.sql | 6 ++++-- .../active_users/int_user_active_days_server_telemetry.sql | 5 +++-- .../int_boards_client_telemetry_daily.sql | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_legacy_telemetry.sql b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_legacy_telemetry.sql index c9e536d52..4df9c5f75 100644 --- a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_legacy_telemetry.sql +++ b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_legacy_telemetry.sql @@ -44,10 +44,11 @@ select , user_id , true as is_active -- Required for incremental loading - , received_at_date + -- Use max to ensure that the most recent received_at_date is used + , max(received_at_date) as received_at_date , {{ dbt_utils.pivot('client_type', ['IS_DESKTOP', 'IS_WEBAPP']) }} from tmp where activity_date >= '{{ var('telemetry_start_date')}}' group by - activity_date, server_id, user_id, received_at_date \ No newline at end of file + activity_date, server_id, user_id \ No newline at end of file diff --git a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_mobile_telemetry.sql b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_mobile_telemetry.sql index d9f05e9c8..078075749 100644 --- a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_mobile_telemetry.sql +++ b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_mobile_telemetry.sql @@ -40,8 +40,10 @@ select , user_id , true as is_active -- Required for incremental loading - , received_at_date + -- Use max to ensure that the most recent received_at_date is used + , max(received_at_date) as received_at_date from tmp where - activity_date >= '{{ var('telemetry_start_date')}}' \ No newline at end of file + activity_date >= '{{ var('telemetry_start_date')}}' +group by activity_date, server_id, user_id \ No newline at end of file diff --git a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_server_telemetry.sql b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_server_telemetry.sql index 9a3a29455..ff39ca310 100644 --- a/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_server_telemetry.sql +++ b/transform/mattermost-analytics/models/intermediate/product/active_users/int_user_active_days_server_telemetry.sql @@ -44,10 +44,11 @@ select , user_id , true as is_active -- Required for incremental loading - , received_at_date + -- Use max to ensure that the most recent received_at_date is used + , max(received_at_date) as received_at_date , {{ dbt_utils.pivot('client_type', ['IS_DESKTOP', 'IS_WEBAPP']) }} from tmp where activity_date >= '{{ var('telemetry_start_date')}}' group by - activity_date, server_id, user_id, received_at_date \ No newline at end of file + activity_date, server_id, user_id \ No newline at end of file diff --git a/transform/mattermost-analytics/models/intermediate/product/boards_active_users/int_boards_client_telemetry_daily.sql b/transform/mattermost-analytics/models/intermediate/product/boards_active_users/int_boards_client_telemetry_daily.sql index b0267bcdb..2dd0802fb 100644 --- a/transform/mattermost-analytics/models/intermediate/product/boards_active_users/int_boards_client_telemetry_daily.sql +++ b/transform/mattermost-analytics/models/intermediate/product/boards_active_users/int_boards_client_telemetry_daily.sql @@ -40,8 +40,10 @@ select , user_id , true as is_active -- Required for incremental loading - , received_at_date + -- Use max to ensure that the most recent received_at_date is used + , max(received_at_date) as received_at_date from tmp where activity_date >= '{{ var('telemetry_start_date')}}' +group by activity_date, server_id, user_id \ No newline at end of file