diff --git a/mobile_verifier/src/rewarder.rs b/mobile_verifier/src/rewarder.rs index d17ee903a..7f22868a7 100644 --- a/mobile_verifier/src/rewarder.rs +++ b/mobile_verifier/src/rewarder.rs @@ -297,6 +297,7 @@ where data_session::clear_hotspot_data_sessions(&mut transaction, &reward_period.start).await?; coverage::clear_coverage_objects(&mut transaction, &reward_period.start).await?; sp_boosted_rewards_bans::clear_bans(&mut transaction, reward_period.start).await?; + subscriber_verified_mapping_event::clear(&mut transaction, &reward_period.end).await?; // subscriber_location::clear_location_shares(&mut transaction, &reward_period.end).await?; let next_reward_period = scheduler.next_reward_period(); diff --git a/mobile_verifier/src/subscriber_verified_mapping_event.rs b/mobile_verifier/src/subscriber_verified_mapping_event.rs index a5e470a9b..a5f0464b0 100644 --- a/mobile_verifier/src/subscriber_verified_mapping_event.rs +++ b/mobile_verifier/src/subscriber_verified_mapping_event.rs @@ -265,7 +265,7 @@ pub async fn aggregate_verified_mapping_events( subscriber_id, SUM(total_reward_points) AS total_reward_points FROM - verified_subscriber_verified_mapping_event + verified_subscriber_verified_mapping_event WHERE received_timestamp >= $1 AND received_timestamp < $2 GROUP BY subscriber_id;", @@ -277,3 +277,16 @@ pub async fn aggregate_verified_mapping_events( Ok(vsme_shares) } + +pub async fn clear( + tx: &mut sqlx::Transaction<'_, sqlx::Postgres>, + timestamp: &DateTime, +) -> Result<(), sqlx::Error> { + sqlx::query( + "DELETE FROM verified_subscriber_verified_mapping_event WHERE received_timestamp < $1", + ) + .bind(timestamp) + .execute(&mut *tx) + .await?; + Ok(()) +}