Skip to content

Commit

Permalink
Change mobile verifier so subscriber rewards are paid to any subscrib…
Browse files Browse the repository at this point in the history
…er eligigle for last 7 days (#582)
  • Loading branch information
bbalser authored Jul 27, 2023
1 parent a6c0f03 commit 4b36f09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mobile_verifier/src/rewarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
7 changes: 5 additions & 2 deletions mobile_verifier/src/subscriber_location.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, Utc};
use chrono::{DateTime, Duration, Utc};
use file_store::{
file_info_poller::FileInfoStream,
file_sink::FileSinkClient,
Expand All @@ -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<Vec<u8>>;

pub struct SubscriberLocationIngestor {
Expand Down Expand Up @@ -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();
Expand All @@ -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<DateTime<Utc>>,
Expand Down

0 comments on commit 4b36f09

Please sign in to comment.