Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change mobile verifier so subscriber rewards are paid to any subscrib… #582

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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