Skip to content

Commit aac6330

Browse files
committed
Fix heartbeat_does_not_use_last_good_location_when_more_than_12_hours
1 parent 09005c7 commit aac6330

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mobile_verifier/src/heartbeats/location_cache.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,13 @@ impl LocationCache {
7373
{
7474
let data = self.data.lock().await;
7575
if let Some(&value) = data.get(&key) {
76-
// TODO: When we get it timestamp more than 12h old should we remove an try to fetch new one?
77-
return Ok(Some(value));
76+
let now = Utc::now();
77+
let twelve_hours_ago = now - Duration::hours(12);
78+
if value.timestamp > twelve_hours_ago {
79+
return Ok(None);
80+
} else {
81+
return Ok(Some(value));
82+
}
7883
}
7984
}
8085
match key {

0 commit comments

Comments
 (0)