From e4dac7003e6f59601ea63001be3163114d736b5a Mon Sep 17 00:00:00 2001 From: Thomas Marchand Date: Tue, 12 Mar 2024 11:18:42 +0100 Subject: [PATCH] fix: warnings --- src/endpoints/addrs_to_domains.rs | 2 +- src/endpoints/referral/click_count.rs | 17 ++++++++--------- src/endpoints/referral/revenue.rs | 17 ++++++++--------- src/endpoints/referral/sales_count.rs | 17 ++++++++--------- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/endpoints/addrs_to_domains.rs b/src/endpoints/addrs_to_domains.rs index 192e12b..0d7bd61 100644 --- a/src/endpoints/addrs_to_domains.rs +++ b/src/endpoints/addrs_to_domains.rs @@ -112,7 +112,7 @@ fn create_legacy_pipeline(addresses: &[String]) -> Vec { vec![ doc! { "$match": { - "legacy_address": { "$in": addresses.clone() }, + "legacy_address": { "$in": addresses }, "_cursor.to": null, "$expr": { "$eq": ["$legacy_address", "$rev_address"] }, }, diff --git a/src/endpoints/referral/click_count.rs b/src/endpoints/referral/click_count.rs index c457091..f90c931 100644 --- a/src/endpoints/referral/click_count.rs +++ b/src/endpoints/referral/click_count.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Json}, }; use axum_auto_routes::route; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{NaiveDateTime, TimeZone, Utc}; use futures::StreamExt; use mongodb::bson::{doc, Bson, DateTime as BsonDateTime}; use serde::{Deserialize, Serialize}; @@ -38,15 +38,14 @@ pub async fn handler( let mut output = Data { counts: vec![] }; let mut i = 0; loop { - let start_time = DateTime::::from_utc( - NaiveDateTime::from_timestamp_opt(query.since_day + i * query.spacing, 0).unwrap(), - Utc, - ); - let end_time = DateTime::::from_utc( + let start_naive_dt = + NaiveDateTime::from_timestamp_opt(query.since_day + i * query.spacing, 0).unwrap(); + let start_time = Utc.from_utc_datetime(&start_naive_dt); + + let end_naive_dt = NaiveDateTime::from_timestamp_opt(query.since_day + (i + 1) * query.spacing, 0) - .unwrap(), - Utc, - ); + .unwrap(); + let end_time = Utc.from_utc_datetime(&end_naive_dt); let documents = sponsor_usage .find( diff --git a/src/endpoints/referral/revenue.rs b/src/endpoints/referral/revenue.rs index 680f11f..95e0441 100644 --- a/src/endpoints/referral/revenue.rs +++ b/src/endpoints/referral/revenue.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Json}, }; use axum_auto_routes::route; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{NaiveDateTime, TimeZone, Utc}; use futures::StreamExt; use mongodb::bson::{doc, Bson, DateTime as BsonDateTime}; use serde::{Deserialize, Serialize}; @@ -38,15 +38,14 @@ pub async fn handler( let mut output = Data { revenues: vec![] }; let mut i = 0; loop { - let start_time = DateTime::::from_utc( - NaiveDateTime::from_timestamp_opt(query.since_date + i * query.spacing, 0).unwrap(), - Utc, - ); - let end_time = DateTime::::from_utc( + let start_naive_dt = + NaiveDateTime::from_timestamp_opt(query.since_date + i * query.spacing, 0).unwrap(); + let start_time = Utc.from_utc_datetime(&start_naive_dt); + + let end_naive_dt = NaiveDateTime::from_timestamp_opt(query.since_date + (i + 1) * query.spacing, 0) - .unwrap(), - Utc, - ); + .unwrap(); + let end_time = Utc.from_utc_datetime(&end_naive_dt); let documents = referral_revenues .find( diff --git a/src/endpoints/referral/sales_count.rs b/src/endpoints/referral/sales_count.rs index f2fe2c9..e9ce579 100644 --- a/src/endpoints/referral/sales_count.rs +++ b/src/endpoints/referral/sales_count.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Json}, }; use axum_auto_routes::route; -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{NaiveDateTime, TimeZone, Utc}; use futures::StreamExt; use mongodb::bson::{doc, Bson, DateTime as BsonDateTime}; use serde::{Deserialize, Serialize}; @@ -38,15 +38,14 @@ pub async fn handler( let mut output = Data { counts: vec![] }; let mut i = 0; loop { - let start_time = DateTime::::from_utc( - NaiveDateTime::from_timestamp_opt(query.since_date + i * query.spacing, 0).unwrap(), - Utc, - ); - let end_time = DateTime::::from_utc( + let start_naive_dt = + NaiveDateTime::from_timestamp_opt(query.since_date + i * query.spacing, 0).unwrap(); + let start_time = Utc.from_utc_datetime(&start_naive_dt); + + let end_naive_dt = NaiveDateTime::from_timestamp_opt(query.since_date + (i + 1) * query.spacing, 0) - .unwrap(), - Utc, - ); + .unwrap(); + let end_time = Utc.from_utc_datetime(&end_naive_dt); let documents = referral_revenues .find(