dont put anon stats in the db (for now)

the indexes need to be fixed. UNIQUE+NULL do not play nice
This commit is contained in:
Bryan Stitt 2023-07-14 22:19:18 -07:00
parent 264508c454
commit 140dc04a8b
2 changed files with 10 additions and 1 deletions

View File

@ -94,6 +94,12 @@ pub struct RpcQueryKey {
rpc_key_user_id: Option<NonZeroU64>,
}
impl RpcQueryKey {
pub fn is_registered(&self) -> bool {
self.rpc_key_user_id.is_some()
}
}
/// round the unix epoch time to the start of a period
fn round_timestamp(timestamp: i64, period_seconds: i64) -> i64 {
timestamp / period_seconds * period_seconds

View File

@ -178,7 +178,10 @@ impl StatBuffer {
approximate_balance_remaining = user_balance.remaining();
}
self.accounting_db_buffer.entry(stat.accounting_key(self.billing_period_seconds)).or_default().add(stat.clone(), approximate_balance_remaining).await;
let accounting_key = stat.accounting_key(self.billing_period_seconds);
if accounting_key.is_registered() {
self.accounting_db_buffer.entry(accounting_key).or_default().add(stat.clone(), approximate_balance_remaining).await;
}
}
if self.influxdb_client.is_some() {