diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index 49ca11ef1..9a269c8d5 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -239,7 +239,7 @@ impl Rewarder { // clear the db of data sessions data & subscriber location data for the epoch data_session::clear_hotspot_data_sessions(&mut transaction, reward_period).await?; - subscriber_location::clear_location_shares(&mut transaction, reward_period).await?; + // subscriber_location::clear_location_shares(&mut transaction, reward_period).await?; let next_reward_period = scheduler.next_reward_period(); save_last_rewarded_end_time(&mut transaction, &next_reward_period.start).await?; diff --git a/mobile_verifier/src/subscriber_location.rs b/mobile_verifier/src/subscriber_location.rs index 2a9fbba61..c3abcb2a8 100644 --- a/mobile_verifier/src/subscriber_location.rs +++ b/mobile_verifier/src/subscriber_location.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, Utc}; +use chrono::{DateTime, Duration, Utc}; use file_store::{ file_info_poller::FileInfoStream, file_sink::FileSinkClient, @@ -18,6 +18,8 @@ use sqlx::{PgPool, Postgres, Transaction}; use std::ops::Range; use tokio::sync::mpsc::Receiver; +const SUBSCRIBER_REWARD_PERIOD_LENGTH_IN_DAYS: i64 = 7; + pub type SubscriberValidatedLocations = Vec>; pub struct SubscriberLocationIngestor { @@ -178,7 +180,7 @@ pub async fn aggregate_location_shares( let mut rows = sqlx::query_as::<_, SubscriberLocationShare>( "select distinct(subscriber_id) from subscriber_loc_verified where received_timestamp >= $1 and received_timestamp < $2", ) - .bind(reward_period.start) + .bind(reward_period.end - Duration::days(SUBSCRIBER_REWARD_PERIOD_LENGTH_IN_DAYS)) .bind(reward_period.end) .fetch(db); let mut location_shares = SubscriberValidatedLocations::new(); @@ -188,6 +190,7 @@ pub async fn aggregate_location_shares( Ok(location_shares) } +#[allow(dead_code)] pub async fn clear_location_shares( tx: &mut sqlx::Transaction<'_, sqlx::Postgres>, reward_period: &Range>,