Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Oct 11, 2024
1 parent fe0bd9c commit af69757
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
36 changes: 3 additions & 33 deletions gravity-info-server/src/transactions/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::transactions::database::{ApiResponse, CustomMsgSendToEth, CustomMsgTr

use actix_web::Responder;
use actix_web::{web, HttpResponse};
use chrono::{DateTime, Datelike, Local, NaiveDateTime, Utc};
use chrono::{DateTime, Datelike, Local, Utc};

use log::error;

Expand Down Expand Up @@ -62,21 +62,7 @@ pub async fn get_all_msg_send_to_eth_transactions(db: web::Data<Arc<DB>>) -> imp

let timestamp = key_parts[2].parse::<i64>().unwrap();

// Convert timestamp to Option<NaiveDateTime>
let naive_opt = NaiveDateTime::from_timestamp_opt(timestamp, 0);

let mut _datetime_utc: Option<DateTime<Utc>> = None;

if let Some(naive_datetime) = naive_opt {
// Convert Option<NaiveDateTime> to DateTime
_datetime_utc =
Some(DateTime::from_naive_utc_and_offset(naive_datetime, Utc));
} else {
error!("Invalid timestamp: {}", timestamp);
continue; // skip this iteration if timestamp is invalid
}

let datetime_utc = _datetime_utc.unwrap(); // we can safely unwrap because of the `continue` above
let datetime_utc = DateTime::from_timestamp(timestamp, 0).unwrap(); // we can safely unwrap because of the `continue` above

let datetime_local: DateTime<Local> = datetime_utc.into();

Expand Down Expand Up @@ -141,23 +127,7 @@ pub async fn get_all_msg_ibc_transfer_transactions(db: web::Data<Arc<DB>>) -> im

let timestamp = key_parts[2].parse::<i64>().unwrap();

// Convert timestamp to Option<NaiveDateTime>
let naive_opt = NaiveDateTime::from_timestamp_opt(timestamp, 0);

let mut _datetime_utc: Option<DateTime<Utc>> = None;

if let Some(naive_datetime) = naive_opt {
// Convert Option<NaiveDateTime> to DateTime
_datetime_utc = Some(DateTime::<Utc>::from_naive_utc_and_offset(
naive_datetime,
Utc,
));
} else {
error!("Invalid timestamp: {}", timestamp);
continue; // skip this iteration if timestamp is invalid
}

let datetime_utc = _datetime_utc.unwrap(); // we can safely unwrap because of the `continue` above
let datetime_utc = DateTime::from_timestamp(timestamp, 0).unwrap(); // we can safely unwrap because of the `continue` above

let datetime_local: DateTime<Local> = datetime_utc.into();

Expand Down
4 changes: 2 additions & 2 deletions gravity-info-server/src/volume.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! This file computes the total volume of Gravity bridge over daily, weekly, and monthly periods, this is an extremely time consuming task
//! becuase we iterate over the metadata of all erc20 in the bridge this task depends on the fast get info loop completing first
use actix_web::cookie::time::Instant;
use actix_web::rt::System;
use clarity::Uint256;
use futures::future::join3;
use futures::future::join_all;
use gravity_utils::error::GravityError;
use log::{info, warn};
use serde::Serialize;
use std::time::Instant;
use std::{
sync::{Arc, RwLock},
thread,
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn bridge_volume_thread() {
});
info!(
"Successfuly updated volume info in {}s!",
start.elapsed().as_seconds_f32()
start.elapsed().as_secs()
);
}
(Err(e), _, _) => warn!("Could not get daily volume {:?}", e),
Expand Down

0 comments on commit af69757

Please sign in to comment.