From d66811ddfa0bfd957cedc6ea2319f9f490498afb Mon Sep 17 00:00:00 2001 From: Anatolii Kurotych Date: Wed, 4 Dec 2024 15:34:13 +0200 Subject: [PATCH] Fix comments --- .../migrations/7_mobile_radio_tracker.sql | 2 +- mobile_config/src/mobile_radio_tracker.rs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mobile_config/migrations/7_mobile_radio_tracker.sql b/mobile_config/migrations/7_mobile_radio_tracker.sql index 66cf5b029..b80d396bc 100644 --- a/mobile_config/migrations/7_mobile_radio_tracker.sql +++ b/mobile_config/migrations/7_mobile_radio_tracker.sql @@ -4,6 +4,6 @@ CREATE TABLE IF NOT EXISTS mobile_radio_tracker ( last_changed_at TIMESTAMPTZ NOT NULL, last_checked_at TIMESTAMPTZ NOT NULL, asserted_location NUMERIC, - asserted_location_change_at TIMESTAMPTZ, + asserted_location_changed_at TIMESTAMPTZ, PRIMARY KEY (entity_key) ); diff --git a/mobile_config/src/mobile_radio_tracker.rs b/mobile_config/src/mobile_radio_tracker.rs index ab0028c2b..cd6fefbd5 100644 --- a/mobile_config/src/mobile_radio_tracker.rs +++ b/mobile_config/src/mobile_radio_tracker.rs @@ -78,7 +78,7 @@ struct TrackedMobileRadio { last_changed_at: DateTime, last_checked_at: DateTime, asserted_location: Option, - asserted_location_change_at: Option>, + asserted_location_changed_at: Option>, } impl TrackedMobileRadio { @@ -89,7 +89,7 @@ impl TrackedMobileRadio { last_changed_at: radio.refreshed_at, last_checked_at: Utc::now(), asserted_location: radio.location, - asserted_location_change_at: None, + asserted_location_changed_at: None, } } @@ -102,7 +102,7 @@ impl TrackedMobileRadio { } if self.asserted_location != radio.location { self.asserted_location = radio.location; - self.asserted_location_change_at = Some(self.last_checked_at); + self.asserted_location_changed_at = Some(radio.refreshed_at); } self @@ -202,7 +202,7 @@ async fn get_tracked_radios( last_changed_at, last_checked_at, asserted_location::bigint, - asserted_location_change_at + asserted_location_changed_at FROM mobile_radio_tracker "#, ) @@ -255,7 +255,7 @@ async fn update_tracked_radios( for chunk in tracked_radios.chunks(BATCH_SIZE) { QueryBuilder::new( - "INSERT INTO mobile_radio_tracker(entity_key, hash, last_changed_at, last_checked_at, asserted_location, asserted_location_change_at)", + "INSERT INTO mobile_radio_tracker(entity_key, hash, last_changed_at, last_checked_at, asserted_location, asserted_location_changed_at)", ) .push_values(chunk, |mut b, tracked_radio| { b.push_bind(&tracked_radio.entity_key) @@ -263,7 +263,7 @@ async fn update_tracked_radios( .push_bind(tracked_radio.last_changed_at) .push_bind(tracked_radio.last_checked_at) .push_bind(tracked_radio.asserted_location) - .push_bind(tracked_radio.asserted_location_change_at); + .push_bind(tracked_radio.asserted_location_changed_at); }) .push( r#" @@ -272,7 +272,7 @@ async fn update_tracked_radios( last_changed_at = EXCLUDED.last_changed_at, last_checked_at = EXCLUDED.last_checked_at, asserted_location = EXCLUDED.asserted_location, - asserted_location_change_at = EXCLUDED.asserted_location_change_at + asserted_location_changed_at = EXCLUDED.asserted_location_changed_at "#, ) .build() @@ -346,7 +346,7 @@ mod tests { let result = identify_changes(stream::iter(vec![radio.clone()]), tracked_radios).await; - assert!(result[0].asserted_location_change_at.is_none()); + assert!(result[0].asserted_location_changed_at.is_none()); assert!(result[0].asserted_location.is_none()); // location is 1 @@ -357,12 +357,12 @@ mod tests { tracked_radios.insert(tracked_radio.entity_key.clone(), tracked_radio); let result = identify_changes(stream::iter(vec![radio.clone()]), tracked_radios).await; - assert!(result[0].asserted_location_change_at.is_none()); + assert!(result[0].asserted_location_changed_at.is_none()); assert_eq!(result[0].asserted_location, Some(1)); } #[tokio::test] - async fn will_update_last_asserted_location_change_at_when_location_changes() { + async fn will_update_last_asserted_location_changed_at_when_location_changes() { let mut radio = mobile_radio(vec![1, 2, 3]); radio.location = None; let tracked_radio = TrackedMobileRadio::new(&radio); @@ -374,8 +374,8 @@ mod tests { let result = identify_changes(stream::iter(vec![radio.clone()]), tracked_radios).await; assert_eq!( - result[0].asserted_location_change_at.unwrap(), - result[0].last_checked_at + result[0].asserted_location_changed_at.unwrap(), + result[0].last_changed_at ); assert_eq!(result[0].asserted_location.unwrap(), 1); @@ -386,8 +386,8 @@ mod tests { let result = identify_changes(stream::iter(vec![radio.clone()]), tracked_radios).await; assert_eq!( - result[0].asserted_location_change_at.unwrap(), - result[0].last_checked_at + result[0].asserted_location_changed_at.unwrap(), + result[0].last_changed_at, ); assert_eq!(result[0].asserted_location.unwrap(), 2); }