chore: address Rust 1.78 clippy lints (#4545)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Chethan Rao
2024-05-07 16:05:32 +05:30
committed by GitHub
parent 99bbc3982f
commit 2216a88d25
222 changed files with 1138 additions and 1631 deletions

View File

@ -453,7 +453,7 @@ where
|(order_column, order)| format!(
" order by {} {}",
order_column.to_owned(),
order.to_string()
order
)
),
alias.map_or_else(|| "".to_owned(), |alias| format!(" as {}", alias))
@ -476,7 +476,7 @@ where
|(order_column, order)| format!(
" order by {} {}",
order_column.to_owned(),
order.to_string()
order
)
),
alias.map_or_else(|| "".to_owned(), |alias| format!(" as {}", alias))

View File

@ -78,14 +78,16 @@ impl Default for AnalyticsProvider {
}
}
impl ToString for AnalyticsProvider {
fn to_string(&self) -> String {
String::from(match self {
impl std::fmt::Display for AnalyticsProvider {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let analytics_provider = match self {
Self::Clickhouse(_) => "Clickhouse",
Self::Sqlx(_) => "Sqlx",
Self::CombinedCkh(_, _) => "CombinedCkh",
Self::CombinedSqlx(_, _) => "CombinedSqlx",
})
};
write!(f, "{}", analytics_provider)
}
}

View File

@ -153,10 +153,7 @@ impl PaymentMetricAccumulator for SumAccumulator {
fn add_metrics_bucket(&mut self, metrics: &PaymentMetricRow) {
self.total = match (
self.total,
metrics
.total
.as_ref()
.and_then(bigdecimal::ToPrimitive::to_i64),
metrics.total.as_ref().and_then(ToPrimitive::to_i64),
) {
(None, None) => None,
(None, i @ Some(_)) | (i @ Some(_), None) => i,
@ -173,10 +170,7 @@ impl PaymentMetricAccumulator for AverageAccumulator {
type MetricOutput = Option<f64>;
fn add_metrics_bucket(&mut self, metrics: &PaymentMetricRow) {
let total = metrics
.total
.as_ref()
.and_then(bigdecimal::ToPrimitive::to_u32);
let total = metrics.total.as_ref().and_then(ToPrimitive::to_u32);
let count = metrics.count.and_then(|total| u32::try_from(total).ok());
match (total, count) {

View File

@ -286,12 +286,12 @@ pub enum Order {
Descending,
}
impl ToString for Order {
fn to_string(&self) -> String {
String::from(match self {
Self::Ascending => "asc",
Self::Descending => "desc",
})
impl std::fmt::Display for Order {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Ascending => write!(f, "asc"),
Self::Descending => write!(f, "desc"),
}
}
}
@ -709,12 +709,12 @@ where
Ok(query)
}
pub async fn execute_query<R, P: AnalyticsDataSource>(
pub async fn execute_query<R, P>(
&mut self,
store: &P,
) -> CustomResult<CustomResult<Vec<R>, QueryExecutionError>, QueryBuildingError>
where
P: LoadRow<R>,
P: LoadRow<R> + AnalyticsDataSource,
Aggregate<&'static str>: ToSql<T>,
Window<&'static str>: ToSql<T>,
{

View File

@ -6,5 +6,4 @@ pub mod metrics;
pub mod types;
pub use accumulator::{RefundMetricAccumulator, RefundMetricsAccumulator};
pub trait RefundAnalytics: metrics::RefundMetricAnalytics {}
pub use self::core::{get_filters, get_metrics};

View File

@ -5,10 +5,5 @@ pub mod filters;
pub mod metrics;
pub mod types;
pub use accumulator::{SdkEventMetricAccumulator, SdkEventMetricsAccumulator};
pub trait SDKEventAnalytics: events::SdkEventsFilterAnalytics {}
pub trait SdkEventAnalytics:
metrics::SdkEventMetricAnalytics + filters::SdkEventFilterAnalytics
{
}
pub use self::core::{get_filters, get_metrics, sdk_events_core};

View File

@ -593,7 +593,7 @@ where
|(order_column, order)| format!(
" order by {} {}",
order_column.to_owned(),
order.to_string()
order
)
),
alias.map_or_else(|| "".to_owned(), |alias| format!(" as {}", alias))
@ -616,7 +616,7 @@ where
|(order_column, order)| format!(
" order by {} {}",
order_column.to_owned(),
order.to_string()
order
)
),
alias.map_or_else(|| "".to_owned(), |alias| format!(" as {}", alias))

View File

@ -63,11 +63,6 @@ where
}
}
// Analytics Framework
pub trait RefundAnalytics {}
pub trait SdkEventAnalytics {}
#[async_trait::async_trait]
pub trait AnalyticsDataSource
where