Skip to content

Commit

Permalink
Merge pull request #637 from helium/jg/mapping-criteria
Browse files Browse the repository at this point in the history
reinstitute mapping event requirements for active mobile subs
  • Loading branch information
jeffgrunewald authored Oct 2, 2023
2 parents c0892be + 81d6d70 commit baf5094
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 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_IN_DAYS: i64 = 1;

pub type SubscriberValidatedLocations = Vec<Vec<u8>>;

pub struct SubscriberLocationIngestor {
Expand Down Expand Up @@ -171,11 +173,13 @@ pub struct SubscriberLocationShare {

pub async fn aggregate_location_shares(
db: impl sqlx::PgExecutor<'_> + Copy,
_reward_period: &Range<DateTime<Utc>>,
reward_period: &Range<DateTime<Utc>>,
) -> Result<SubscriberValidatedLocations, sqlx::Error> {
let mut rows = sqlx::query_as::<_, SubscriberLocationShare>(
"select distinct(subscriber_id) from subscriber_loc_verified",
"select distinct(subscriber_id) from subscriber_loc_verified where received_timestamp >= $1 and received_timestamp < $2",
)
.bind(reward_period.end - Duration::days(SUBSCRIBER_REWARD_PERIOD_IN_DAYS))
.bind(reward_period.end)
.fetch(db);
let mut location_shares = SubscriberValidatedLocations::new();
while let Some(share) = rows.try_next().await? {
Expand Down

0 comments on commit baf5094

Please sign in to comment.