diff --git a/mobile_config/src/mobile_radio_tracker.rs b/mobile_config/src/mobile_radio_tracker.rs index dcbfb2c27..3972dfa06 100644 --- a/mobile_config/src/mobile_radio_tracker.rs +++ b/mobile_config/src/mobile_radio_tracker.rs @@ -208,21 +208,10 @@ pub async fn get_tracked_radios( fn get_all_mobile_radios(metadata: &Pool) -> impl Stream + '_ { sqlx::query_as::<_, MobileRadio>( r#" - WITH unique_entity_keys AS ( - SELECT - kta.entity_key as entity_key, - kta.asset as asset, - MAX(mhi.refreshed_at) AS refreshed_at - FROM key_to_assets kta - INNER JOIN mobile_hotspot_infos mhi - ON kta.asset = mhi.asset - WHERE kta.entity_key IS NOT NULL - AND mhi.refreshed_at IS NOT NULL - GROUP BY kta.entity_key, kta.asset - ) - SELECT - uek.entity_key, + DISTINCT ON (kta.entity_key, mhi.asset) + kta.entity_key, + mhi.asset, mhi.refreshed_at, mhi.location::bigint, mhi.is_full_hotspot::int, @@ -231,9 +220,12 @@ fn get_all_mobile_radios(metadata: &Pool) -> impl Stream