From 63ec8ff0e718d26fe9c6872a40da3cc4b7d62921 Mon Sep 17 00:00:00 2001 From: Sanchith Hegde Date: Mon, 2 Dec 2024 00:51:07 +0530 Subject: [PATCH 1/4] chore: enable `clippy::trivially_copy_pass_by_ref` lint and address it --- Cargo.toml | 1 + crates/analytics/src/api_event/core.rs | 2 +- crates/analytics/src/api_event/metrics.rs | 4 +- .../src/api_event/metrics/api_count.rs | 4 +- .../src/api_event/metrics/latency.rs | 4 +- .../api_event/metrics/status_code_count.rs | 4 +- crates/analytics/src/auth_events/core.rs | 2 +- crates/analytics/src/auth_events/metrics.rs | 4 +- .../metrics/authentication_attempt_count.rs | 4 +- .../metrics/authentication_success_count.rs | 4 +- .../metrics/challenge_attempt_count.rs | 4 +- .../metrics/challenge_flow_count.rs | 4 +- .../metrics/challenge_success_count.rs | 4 +- .../metrics/frictionless_flow_count.rs | 4 +- .../metrics/frictionless_success_count.rs | 4 +- .../auth_events/metrics/three_ds_sdk_count.rs | 4 +- crates/analytics/src/disputes/core.rs | 2 +- crates/analytics/src/disputes/metrics.rs | 4 +- .../disputes/metrics/dispute_status_metric.rs | 4 +- .../dispute_status_metric.rs | 4 +- .../total_amount_disputed.rs | 4 +- .../total_dispute_lost_amount.rs | 4 +- .../disputes/metrics/total_amount_disputed.rs | 4 +- .../metrics/total_dispute_lost_amount.rs | 4 +- crates/analytics/src/frm/core.rs | 2 +- crates/analytics/src/frm/metrics.rs | 4 +- .../src/frm/metrics/frm_blocked_rate.rs | 4 +- .../src/frm/metrics/frm_triggered_attempts.rs | 4 +- crates/analytics/src/lib.rs | 18 ++++----- crates/analytics/src/opensearch.rs | 6 +-- crates/analytics/src/payment_intents/core.rs | 2 +- .../analytics/src/payment_intents/metrics.rs | 4 +- .../metrics/payment_intent_count.rs | 4 +- .../metrics/payment_processed_amount.rs | 4 +- .../metrics/payments_success_rate.rs | 4 +- .../payment_intent_count.rs | 4 +- .../payment_processed_amount.rs | 4 +- .../payments_distribution.rs | 4 +- .../payments_success_rate.rs | 4 +- .../smart_retried_amount.rs | 4 +- .../successful_smart_retries.rs | 4 +- .../total_smart_retries.rs | 4 +- .../metrics/smart_retried_amount.rs | 4 +- .../metrics/successful_smart_retries.rs | 4 +- .../metrics/total_smart_retries.rs | 4 +- crates/analytics/src/payments/core.rs | 4 +- crates/analytics/src/payments/distribution.rs | 4 +- .../distribution/payment_error_message.rs | 4 +- crates/analytics/src/payments/metrics.rs | 4 +- .../src/payments/metrics/avg_ticket_size.rs | 4 +- .../metrics/connector_success_rate.rs | 4 +- .../src/payments/metrics/payment_count.rs | 4 +- .../metrics/payment_processed_amount.rs | 4 +- .../payments/metrics/payment_success_count.rs | 4 +- .../src/payments/metrics/retries_count.rs | 4 +- .../sessionized_metrics/avg_ticket_size.rs | 4 +- .../connector_success_rate.rs | 4 +- .../sessionized_metrics/failure_reasons.rs | 4 +- .../sessionized_metrics/payment_count.rs | 4 +- .../payment_processed_amount.rs | 4 +- .../payment_success_count.rs | 4 +- .../payments_distribution.rs | 4 +- .../sessionized_metrics/retries_count.rs | 4 +- .../sessionized_metrics/success_rate.rs | 4 +- .../src/payments/metrics/success_rate.rs | 4 +- crates/analytics/src/query.rs | 8 ++-- crates/analytics/src/refunds/core.rs | 2 +- crates/analytics/src/refunds/metrics.rs | 4 +- .../src/refunds/metrics/refund_count.rs | 4 +- .../metrics/refund_processed_amount.rs | 4 +- .../refunds/metrics/refund_success_count.rs | 4 +- .../refunds/metrics/refund_success_rate.rs | 4 +- .../sessionized_metrics/refund_count.rs | 4 +- .../refund_processed_amount.rs | 4 +- .../refund_success_count.rs | 4 +- .../refund_success_rate.rs | 4 +- crates/analytics/src/sdk_events/core.rs | 2 +- crates/analytics/src/sdk_events/metrics.rs | 4 +- .../metrics/average_payment_time.rs | 4 +- .../src/sdk_events/metrics/load_time.rs | 4 +- .../sdk_events/metrics/payment_attempts.rs | 4 +- .../metrics/payment_data_filled_count.rs | 4 +- .../metrics/payment_method_selected_count.rs | 4 +- .../metrics/payment_methods_call_count.rs | 4 +- .../sdk_events/metrics/sdk_initiated_count.rs | 4 +- .../sdk_events/metrics/sdk_rendered_count.rs | 4 +- crates/api_models/src/connector_enums.rs | 26 ++++++------- crates/common_enums/src/enums.rs | 24 ++++++------ crates/common_enums/src/transformers.rs | 18 +++++++-- crates/common_utils/src/id_type.rs | 4 +- crates/common_utils/src/id_type/global_id.rs | 2 +- crates/common_utils/src/types.rs | 2 +- .../src/connectors/cashtocode.rs | 4 +- .../src/connectors/cashtocode/transformers.rs | 3 +- .../src/connectors/powertranz/transformers.rs | 4 +- .../src/connectors/worldline.rs | 4 +- crates/kgraph_utils/src/mca.rs | 6 +-- crates/router/src/bin/router.rs | 2 +- .../src/connector/adyen/transformers.rs | 4 +- .../src/connector/paybox/transformers.rs | 17 +++------ crates/router/src/connector/rapyd.rs | 12 +++--- crates/router/src/core/admin.rs | 1 - crates/router/src/core/payment_link.rs | 6 +-- crates/router/src/core/payment_methods.rs | 4 +- .../router/src/core/payment_methods/cards.rs | 16 ++++---- .../router/src/core/payment_methods/utils.rs | 30 +++++++-------- .../router/src/core/payment_methods/vault.rs | 9 ++--- crates/router/src/core/payments.rs | 28 +++++++------- .../src/core/payments/flows/session_flow.rs | 12 +++--- crates/router/src/core/payments/helpers.rs | 12 +++--- .../payments/operations/payment_approve.rs | 2 +- .../payments/operations/payment_cancel.rs | 2 +- .../operations/payment_complete_authorize.rs | 2 +- .../payments/operations/payment_confirm.rs | 4 +- .../payments/operations/payment_reject.rs | 2 +- .../payments/operations/payment_session.rs | 2 +- .../core/payments/operations/payment_start.rs | 2 +- .../payments/operations/payment_status.rs | 2 +- .../payments/operations/payment_update.rs | 2 +- .../payments_incremental_authorization.rs | 2 +- .../payments/operations/tax_calculation.rs | 2 +- .../router/src/core/payments/transformers.rs | 2 +- crates/router/src/core/payout_link.rs | 6 +-- crates/router/src/core/payouts.rs | 2 +- crates/router/src/core/payouts/helpers.rs | 4 +- crates/router/src/core/routing.rs | 8 ++-- crates/router/src/core/routing/helpers.rs | 8 ++-- crates/router/src/core/user.rs | 2 +- .../src/core/user/dashboard_metadata.rs | 8 ++-- crates/router/src/core/utils.rs | 6 +-- crates/router/src/routes/app.rs | 6 +-- .../routes/metrics/bg_metrics_collector.rs | 2 +- crates/router/src/routes/routing.rs | 4 +- crates/router/src/services/authentication.rs | 38 +++++++++---------- crates/router/src/services/authorization.rs | 2 +- .../authorization/permission_groups.rs | 4 +- .../src/services/authorization/permissions.rs | 4 +- .../src/services/authorization/roles.rs | 2 +- crates/router/src/types/api.rs | 8 ++-- crates/router/src/utils/user.rs | 2 +- .../src/utils/user/dashboard_metadata.rs | 2 +- crates/router/tests/connectors/payeezy.rs | 2 +- .../src/macros/to_encryptable.rs | 8 ++-- crates/router_env/src/logger/config.rs | 2 +- crates/router_env/src/logger/formatter.rs | 13 +++---- crates/scheduler/src/utils.rs | 4 +- crates/storage_impl/src/lib.rs | 4 +- crates/storage_impl/src/lookup.rs | 4 +- .../src/payments/payment_attempt.rs | 32 ++++++++-------- .../src/payments/payment_intent.rs | 14 +++---- .../src/payouts/payout_attempt.rs | 10 ++--- crates/storage_impl/src/payouts/payouts.rs | 14 +++---- 152 files changed, 424 insertions(+), 424 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 38d895d767af..dc60c64f667e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ panicking_unwrap = "warn" print_stderr = "warn" print_stdout = "warn" todo = "warn" +trivially_copy_pass_by_ref = "warn" unimplemented = "warn" unnecessary_self_imports = "warn" unreachable = "warn" diff --git a/crates/analytics/src/api_event/core.rs b/crates/analytics/src/api_event/core.rs index 305de7e69c86..425d1476a476 100644 --- a/crates/analytics/src/api_event/core.rs +++ b/crates/analytics/src/api_event/core.rs @@ -118,7 +118,7 @@ pub async fn get_api_event_metrics( &req.group_by_names.clone(), &merchant_id_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/api_event/metrics.rs b/crates/analytics/src/api_event/metrics.rs index ac29ec15169f..ad49f5d0ccd9 100644 --- a/crates/analytics/src/api_event/metrics.rs +++ b/crates/analytics/src/api_event/metrics.rs @@ -45,7 +45,7 @@ where dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -66,7 +66,7 @@ where dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/api_event/metrics/api_count.rs b/crates/analytics/src/api_event/metrics/api_count.rs index f00c01bbf381..85f6cac01cec 100644 --- a/crates/analytics/src/api_event/metrics/api_count.rs +++ b/crates/analytics/src/api_event/metrics/api_count.rs @@ -32,7 +32,7 @@ where _dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -62,7 +62,7 @@ where alias: Some("end_bucket"), }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/api_event/metrics/latency.rs b/crates/analytics/src/api_event/metrics/latency.rs index 5d71da2a0aa1..03c1a226e441 100644 --- a/crates/analytics/src/api_event/metrics/latency.rs +++ b/crates/analytics/src/api_event/metrics/latency.rs @@ -35,7 +35,7 @@ where _dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -67,7 +67,7 @@ where alias: Some("end_bucket"), }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/api_event/metrics/status_code_count.rs b/crates/analytics/src/api_event/metrics/status_code_count.rs index b4fff367b629..f67d3d73e593 100644 --- a/crates/analytics/src/api_event/metrics/status_code_count.rs +++ b/crates/analytics/src/api_event/metrics/status_code_count.rs @@ -32,7 +32,7 @@ where _dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -68,7 +68,7 @@ where alias: Some("end_bucket"), }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/auth_events/core.rs b/crates/analytics/src/auth_events/core.rs index 250dc07fee74..3fd134bc4980 100644 --- a/crates/analytics/src/auth_events/core.rs +++ b/crates/analytics/src/auth_events/core.rs @@ -38,7 +38,7 @@ pub async fn get_metrics( &metric_type, &merchant_id_scoped, &publishable_key_scoped, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/auth_events/metrics.rs b/crates/analytics/src/auth_events/metrics.rs index da5bf6309fe4..4a1fbd0e1470 100644 --- a/crates/analytics/src/auth_events/metrics.rs +++ b/crates/analytics/src/auth_events/metrics.rs @@ -46,7 +46,7 @@ where &self, merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -66,7 +66,7 @@ where &self, merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs b/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs index 4fee15e2afd1..5faeefec6861 100644 --- a/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs +++ b/crates/analytics/src/auth_events/metrics/authentication_attempt_count.rs @@ -31,7 +31,7 @@ where &self, _merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/authentication_success_count.rs b/crates/analytics/src/auth_events/metrics/authentication_success_count.rs index 06de7a694fc8..663473c2d895 100644 --- a/crates/analytics/src/auth_events/metrics/authentication_success_count.rs +++ b/crates/analytics/src/auth_events/metrics/authentication_success_count.rs @@ -31,7 +31,7 @@ where &self, _merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs b/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs index 2f744f15e909..15cd86e5cc8d 100644 --- a/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs +++ b/crates/analytics/src/auth_events/metrics/challenge_attempt_count.rs @@ -31,7 +31,7 @@ where &self, merchant_id: &common_utils::id_type::MerchantId, _publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs b/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs index 551810d8e5a7..61b10e6fb9e9 100644 --- a/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs +++ b/crates/analytics/src/auth_events/metrics/challenge_flow_count.rs @@ -31,7 +31,7 @@ where &self, _merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/challenge_success_count.rs b/crates/analytics/src/auth_events/metrics/challenge_success_count.rs index c6c7d1cda08d..c5bf7bf81cec 100644 --- a/crates/analytics/src/auth_events/metrics/challenge_success_count.rs +++ b/crates/analytics/src/auth_events/metrics/challenge_success_count.rs @@ -31,7 +31,7 @@ where &self, merchant_id: &common_utils::id_type::MerchantId, _publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs b/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs index 69b4eeba4a61..c08cc511e169 100644 --- a/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs +++ b/crates/analytics/src/auth_events/metrics/frictionless_flow_count.rs @@ -31,7 +31,7 @@ where &self, _merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs b/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs index 6ea26a909799..b310567c9db3 100644 --- a/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs +++ b/crates/analytics/src/auth_events/metrics/frictionless_success_count.rs @@ -31,7 +31,7 @@ where &self, merchant_id: &common_utils::id_type::MerchantId, _publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs b/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs index ca67400a9b2e..4ce10c9aad37 100644 --- a/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs +++ b/crates/analytics/src/auth_events/metrics/three_ds_sdk_count.rs @@ -31,7 +31,7 @@ where &self, _merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -45,7 +45,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/disputes/core.rs b/crates/analytics/src/disputes/core.rs index 85d1a62a1d94..f4235518b2d2 100644 --- a/crates/analytics/src/disputes/core.rs +++ b/crates/analytics/src/disputes/core.rs @@ -54,7 +54,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &auth_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/disputes/metrics.rs b/crates/analytics/src/disputes/metrics.rs index ad7ed81aaeee..6514e5fcbe0c 100644 --- a/crates/analytics/src/disputes/metrics.rs +++ b/crates/analytics/src/disputes/metrics.rs @@ -52,7 +52,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -73,7 +73,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/disputes/metrics/dispute_status_metric.rs b/crates/analytics/src/disputes/metrics/dispute_status_metric.rs index bbce460e475c..ce962e284f6f 100644 --- a/crates/analytics/src/disputes/metrics/dispute_status_metric.rs +++ b/crates/analytics/src/disputes/metrics/dispute_status_metric.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -80,7 +80,7 @@ where .add_group_by_clause("dispute_status") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs b/crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs index c5c0b91a173d..9a7b05358192 100644 --- a/crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs +++ b/crates/analytics/src/disputes/metrics/sessionized_metrics/dispute_status_metric.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -80,7 +80,7 @@ where .add_group_by_clause("dispute_status") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs b/crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs index 0767bdaf85d2..5c5eceb06196 100644 --- a/crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs +++ b/crates/analytics/src/disputes/metrics/sessionized_metrics/total_amount_disputed.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -78,7 +78,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs b/crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs index f4f4d8608620..d6308b09f33b 100644 --- a/crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs +++ b/crates/analytics/src/disputes/metrics/sessionized_metrics/total_dispute_lost_amount.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -78,7 +78,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/disputes/metrics/total_amount_disputed.rs b/crates/analytics/src/disputes/metrics/total_amount_disputed.rs index 5b9d0f54622f..68c7fa6d166c 100644 --- a/crates/analytics/src/disputes/metrics/total_amount_disputed.rs +++ b/crates/analytics/src/disputes/metrics/total_amount_disputed.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -77,7 +77,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs b/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs index e13f3a0f5305..d14d49827010 100644 --- a/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs +++ b/crates/analytics/src/disputes/metrics/total_dispute_lost_amount.rs @@ -32,7 +32,7 @@ where dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -77,7 +77,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/frm/core.rs b/crates/analytics/src/frm/core.rs index d2b79ad2773b..6f120913a7a4 100644 --- a/crates/analytics/src/frm/core.rs +++ b/crates/analytics/src/frm/core.rs @@ -47,7 +47,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &merchant_id_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/frm/metrics.rs b/crates/analytics/src/frm/metrics.rs index 7f5b4ea32be3..b3780dfd3cbd 100644 --- a/crates/analytics/src/frm/metrics.rs +++ b/crates/analytics/src/frm/metrics.rs @@ -44,7 +44,7 @@ where dimensions: &[FrmDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &FrmFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -65,7 +65,7 @@ where dimensions: &[FrmDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &FrmFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/frm/metrics/frm_blocked_rate.rs b/crates/analytics/src/frm/metrics/frm_blocked_rate.rs index 7154478c0267..00903cdcaef0 100644 --- a/crates/analytics/src/frm/metrics/frm_blocked_rate.rs +++ b/crates/analytics/src/frm/metrics/frm_blocked_rate.rs @@ -29,7 +29,7 @@ where dimensions: &[FrmDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &FrmFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -76,7 +76,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs b/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs index 168a256ffa62..dd487cdc93f7 100644 --- a/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs +++ b/crates/analytics/src/frm/metrics/frm_triggered_attempts.rs @@ -30,7 +30,7 @@ where dimensions: &[FrmDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &FrmFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -77,7 +77,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/lib.rs b/crates/analytics/src/lib.rs index 224cd82ccd30..eb93a197992e 100644 --- a/crates/analytics/src/lib.rs +++ b/crates/analytics/src/lib.rs @@ -115,7 +115,7 @@ impl AnalyticsProvider { dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { // Metrics to get the fetch time for each payment metric @@ -219,7 +219,7 @@ impl AnalyticsProvider { dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { // Metrics to get the fetch time for each payment metric @@ -329,7 +329,7 @@ impl AnalyticsProvider { dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { @@ -434,7 +434,7 @@ impl AnalyticsProvider { dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { // Metrics to get the fetch time for each refund metric @@ -534,7 +534,7 @@ impl AnalyticsProvider { dimensions: &[FrmDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &FrmFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { // Metrics to get the fetch time for each refund metric @@ -634,7 +634,7 @@ impl AnalyticsProvider { dimensions: &[DisputeDimensions], auth: &AuthInfo, filters: &DisputeFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { // Metrics to get the fetch time for each refund metric @@ -734,7 +734,7 @@ impl AnalyticsProvider { dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { match self { @@ -799,7 +799,7 @@ impl AnalyticsProvider { metric: &AuthEventMetrics, merchant_id: &common_utils::id_type::MerchantId, publishable_key: &str, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { match self { @@ -830,7 +830,7 @@ impl AnalyticsProvider { dimensions: &[ApiEventDimensions], merchant_id: &common_utils::id_type::MerchantId, filters: &ApiEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, ) -> types::MetricsResult> { match self { diff --git a/crates/analytics/src/opensearch.rs b/crates/analytics/src/opensearch.rs index 246a0f4e8bb3..e85340e49d2d 100644 --- a/crates/analytics/src/opensearch.rs +++ b/crates/analytics/src/opensearch.rs @@ -497,7 +497,7 @@ impl OpenSearchQueryBuilder { Ok(()) } - pub fn get_status_field(&self, index: &SearchIndex) -> &str { + pub fn get_status_field(&self, index: SearchIndex) -> &str { match index { SearchIndex::Refunds | SearchIndex::SessionizerRefunds => "refund_status.keyword", SearchIndex::Disputes | SearchIndex::SessionizerDisputes => "dispute_status.keyword", @@ -544,7 +544,7 @@ impl OpenSearchQueryBuilder { mut payload: Value, case_insensitive_filters: &[&(String, Vec)], auth_array: Vec, - index: &SearchIndex, + index: SearchIndex, ) -> Value { let mut must_array = case_insensitive_filters .iter() @@ -728,7 +728,7 @@ impl OpenSearchQueryBuilder { payload, &case_insensitive_filters, should_array.clone(), - index, + *index, ); payload }) diff --git a/crates/analytics/src/payment_intents/core.rs b/crates/analytics/src/payment_intents/core.rs index 0b66dfda58ca..80cfc5630710 100644 --- a/crates/analytics/src/payment_intents/core.rs +++ b/crates/analytics/src/payment_intents/core.rs @@ -98,7 +98,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &auth_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/payment_intents/metrics.rs b/crates/analytics/src/payment_intents/metrics.rs index ee3d4773e243..c063b3a7c044 100644 --- a/crates/analytics/src/payment_intents/metrics.rs +++ b/crates/analytics/src/payment_intents/metrics.rs @@ -66,7 +66,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -87,7 +87,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> diff --git a/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs b/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs index b301a9b9b23b..424901ca7e41 100644 --- a/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs +++ b/crates/analytics/src/payment_intents/metrics/payment_intent_count.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -82,7 +82,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs b/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs index 696dd6a584b6..d913bfe9a344 100644 --- a/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs +++ b/crates/analytics/src/payment_intents/metrics/payment_processed_amount.rs @@ -36,7 +36,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -103,7 +103,7 @@ where .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/payments_success_rate.rs b/crates/analytics/src/payment_intents/metrics/payments_success_rate.rs index 4bb9dc36b078..dda3e37d39a0 100644 --- a/crates/analytics/src/payment_intents/metrics/payments_success_rate.rs +++ b/crates/analytics/src/payment_intents/metrics/payments_success_rate.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -86,7 +86,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_intent_count.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_intent_count.rs index 7475a75bb532..3f0f3bc3bc8a 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_intent_count.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_intent_count.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -82,7 +82,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_processed_amount.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_processed_amount.rs index 0f13ff39af76..11b630a55cc1 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_processed_amount.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payment_processed_amount.rs @@ -36,7 +36,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -105,7 +105,7 @@ where .add_group_by_clause("currency") .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_distribution.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_distribution.rs index 437b22aac716..dbb6d33e907e 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_distribution.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_distribution.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -94,7 +94,7 @@ where .add_group_by_clause("first_attempt") .attach_printable("Error grouping by first_attempt") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_success_rate.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_success_rate.rs index 9716c7ce4deb..178d9c1d816b 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_success_rate.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/payments_success_rate.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -95,7 +95,7 @@ where .attach_printable("Error grouping by first_attempt") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/smart_retried_amount.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/smart_retried_amount.rs index c6d7c59f240d..40e41253d777 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/smart_retried_amount.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/smart_retried_amount.rs @@ -41,7 +41,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -107,7 +107,7 @@ where .add_group_by_clause("currency") .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/successful_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/successful_smart_retries.rs index 0b28cb5366d6..84f6d31dfc6f 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/successful_smart_retries.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/successful_smart_retries.rs @@ -41,7 +41,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -92,7 +92,7 @@ where .attach_printable("Error grouping by dimensions") .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/total_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/total_smart_retries.rs index 20ef8be62770..8cc4e75b3ba7 100644 --- a/crates/analytics/src/payment_intents/metrics/sessionized_metrics/total_smart_retries.rs +++ b/crates/analytics/src/payment_intents/metrics/sessionized_metrics/total_smart_retries.rs @@ -38,7 +38,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -87,7 +87,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs b/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs index f8acb2e6e9ac..d51cb4cdf739 100644 --- a/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs +++ b/crates/analytics/src/payment_intents/metrics/smart_retried_amount.rs @@ -41,7 +41,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -99,7 +99,7 @@ where .add_group_by_clause("currency") .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs index a19bdec518c4..524b3ff29393 100644 --- a/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs +++ b/crates/analytics/src/payment_intents/metrics/successful_smart_retries.rs @@ -41,7 +41,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -92,7 +92,7 @@ where .attach_printable("Error grouping by dimensions") .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs b/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs index f5539abd9f50..8eb561d38d5d 100644 --- a/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs +++ b/crates/analytics/src/payment_intents/metrics/total_smart_retries.rs @@ -38,7 +38,7 @@ where dimensions: &[PaymentIntentDimensions], auth: &AuthInfo, filters: &PaymentIntentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -87,7 +87,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/core.rs b/crates/analytics/src/payments/core.rs index 01a3b1abc15c..c6f0276c47f4 100644 --- a/crates/analytics/src/payments/core.rs +++ b/crates/analytics/src/payments/core.rs @@ -78,7 +78,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &auth_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await @@ -106,7 +106,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &auth_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/payments/distribution.rs b/crates/analytics/src/payments/distribution.rs index 213b62445747..055cbd0f4720 100644 --- a/crates/analytics/src/payments/distribution.rs +++ b/crates/analytics/src/payments/distribution.rs @@ -57,7 +57,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -79,7 +79,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/payments/distribution/payment_error_message.rs b/crates/analytics/src/payments/distribution/payment_error_message.rs index 241754ee0417..9a536f7808f8 100644 --- a/crates/analytics/src/payments/distribution/payment_error_message.rs +++ b/crates/analytics/src/payments/distribution/payment_error_message.rs @@ -35,7 +35,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -89,7 +89,7 @@ where .attach_printable("Error grouping by distribution_for") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics.rs b/crates/analytics/src/payments/metrics.rs index 23b133ad035c..71d2e57d7fa3 100644 --- a/crates/analytics/src/payments/metrics.rs +++ b/crates/analytics/src/payments/metrics.rs @@ -68,7 +68,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -89,7 +89,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/payments/metrics/avg_ticket_size.rs b/crates/analytics/src/payments/metrics/avg_ticket_size.rs index fc2f44cada26..10f350e30ce4 100644 --- a/crates/analytics/src/payments/metrics/avg_ticket_size.rs +++ b/crates/analytics/src/payments/metrics/avg_ticket_size.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -85,7 +85,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/connector_success_rate.rs b/crates/analytics/src/payments/metrics/connector_success_rate.rs index 36783eda72ae..9e6bf31fbfb9 100644 --- a/crates/analytics/src/payments/metrics/connector_success_rate.rs +++ b/crates/analytics/src/payments/metrics/connector_success_rate.rs @@ -36,7 +36,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -87,7 +87,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/payment_count.rs b/crates/analytics/src/payments/metrics/payment_count.rs index bd0b52d7cf83..297aef4fec50 100644 --- a/crates/analytics/src/payments/metrics/payment_count.rs +++ b/crates/analytics/src/payments/metrics/payment_count.rs @@ -33,7 +33,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -78,7 +78,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/payment_processed_amount.rs b/crates/analytics/src/payments/metrics/payment_processed_amount.rs index fa54c1730416..958469246650 100644 --- a/crates/analytics/src/payments/metrics/payment_processed_amount.rs +++ b/crates/analytics/src/payments/metrics/payment_processed_amount.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -85,7 +85,7 @@ where .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/payment_success_count.rs b/crates/analytics/src/payments/metrics/payment_success_count.rs index ea926761c131..843e28589772 100644 --- a/crates/analytics/src/payments/metrics/payment_success_count.rs +++ b/crates/analytics/src/payments/metrics/payment_success_count.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -79,7 +79,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/retries_count.rs b/crates/analytics/src/payments/metrics/retries_count.rs index 9695e1fe18b2..ced845651cf3 100644 --- a/crates/analytics/src/payments/metrics/retries_count.rs +++ b/crates/analytics/src/payments/metrics/retries_count.rs @@ -39,7 +39,7 @@ where _dimensions: &[PaymentDimensions], auth: &AuthInfo, _filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -82,7 +82,7 @@ where .attach_printable("Error filtering time range") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/avg_ticket_size.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/avg_ticket_size.rs index b7f136679176..e29c19bda882 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/avg_ticket_size.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/avg_ticket_size.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -86,7 +86,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/connector_success_rate.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/connector_success_rate.rs index 66006c15a2a4..d8ee7fcb473b 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/connector_success_rate.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/connector_success_rate.rs @@ -36,7 +36,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -88,7 +88,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/failure_reasons.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/failure_reasons.rs index c472c12795f7..d6944d8d0bdf 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/failure_reasons.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/failure_reasons.rs @@ -37,7 +37,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -136,7 +136,7 @@ where .attach_printable("Error grouping by first_attempt") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut outer_query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_count.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_count.rs index 29d083dd232e..98735b9383a6 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_count.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_count.rs @@ -33,7 +33,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -79,7 +79,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_processed_amount.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_processed_amount.rs index a315b2fc4c82..453f988d229d 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_processed_amount.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_processed_amount.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -103,7 +103,7 @@ where .attach_printable("Error grouping by currency") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs index b307b77d5da5..14391588b484 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/payment_success_count.rs @@ -34,7 +34,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -80,7 +80,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/payments_distribution.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/payments_distribution.rs index e0987dd0d225..5c6a8c6adecf 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/payments_distribution.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/payments_distribution.rs @@ -33,7 +33,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -89,7 +89,7 @@ where .add_group_by_clause("first_attempt") .attach_printable("Error grouping by first_attempt") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/retries_count.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/retries_count.rs index b79489744ccf..7d81c48274b1 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/retries_count.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/retries_count.rs @@ -39,7 +39,7 @@ where _dimensions: &[PaymentDimensions], auth: &AuthInfo, _filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -82,7 +82,7 @@ where .attach_printable("Error filtering time range") .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/sessionized_metrics/success_rate.rs b/crates/analytics/src/payments/metrics/sessionized_metrics/success_rate.rs index 30e7471d608d..f20308ed3b1b 100644 --- a/crates/analytics/src/payments/metrics/sessionized_metrics/success_rate.rs +++ b/crates/analytics/src/payments/metrics/sessionized_metrics/success_rate.rs @@ -33,7 +33,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -82,7 +82,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/payments/metrics/success_rate.rs b/crates/analytics/src/payments/metrics/success_rate.rs index e756115a67db..6698fe8ce654 100644 --- a/crates/analytics/src/payments/metrics/success_rate.rs +++ b/crates/analytics/src/payments/metrics/success_rate.rs @@ -33,7 +33,7 @@ where dimensions: &[PaymentDimensions], auth: &AuthInfo, filters: &PaymentFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -81,7 +81,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs index caa112ec1759..a90abffdee53 100644 --- a/crates/analytics/src/query.rs +++ b/crates/analytics/src/query.rs @@ -379,7 +379,7 @@ impl Default for Filter { impl ToSql for Filter { fn to_sql(&self, table_engine: &TableEngine) -> error_stack::Result { Ok(match self { - Self::Plain(l, op, r) => filter_type_to_sql(l, op, r), + Self::Plain(l, op, r) => filter_type_to_sql(l, *op, r), Self::NestedFilter(operator, filters) => { format!( "( {} )", @@ -535,7 +535,7 @@ pub enum FilterTypes { IsNotNull, } -pub fn filter_type_to_sql(l: &String, op: &FilterTypes, r: &String) -> String { +pub fn filter_type_to_sql(l: &str, op: FilterTypes, r: &str) -> String { match op { FilterTypes::EqualBool => format!("{l} = {r}"), FilterTypes::Equal => format!("{l} = '{r}'"), @@ -742,7 +742,7 @@ where Ok(()) } - pub fn add_granularity_in_mins(&mut self, granularity: &Granularity) -> QueryResult<()> { + pub fn add_granularity_in_mins(&mut self, granularity: Granularity) -> QueryResult<()> { let interval = match granularity { Granularity::OneMin => "1", Granularity::FiveMin => "5", @@ -813,7 +813,7 @@ where pub fn get_filter_type_clause(&self) -> Option { self.having.as_ref().map(|vec| { vec.iter() - .map(|(l, op, r)| filter_type_to_sql(l, op, r)) + .map(|(l, op, r)| filter_type_to_sql(l, *op, r)) .collect::>() .join(" AND ") }) diff --git a/crates/analytics/src/refunds/core.rs b/crates/analytics/src/refunds/core.rs index e3bfa4da9d10..259cf812d21d 100644 --- a/crates/analytics/src/refunds/core.rs +++ b/crates/analytics/src/refunds/core.rs @@ -57,7 +57,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &auth_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/refunds/metrics.rs b/crates/analytics/src/refunds/metrics.rs index c211ea82d7af..f7348514e43f 100644 --- a/crates/analytics/src/refunds/metrics.rs +++ b/crates/analytics/src/refunds/metrics.rs @@ -56,7 +56,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -77,7 +77,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/refunds/metrics/refund_count.rs b/crates/analytics/src/refunds/metrics/refund_count.rs index 07de04c58983..827588f888c1 100644 --- a/crates/analytics/src/refunds/metrics/refund_count.rs +++ b/crates/analytics/src/refunds/metrics/refund_count.rs @@ -33,7 +33,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -78,7 +78,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/refunds/metrics/refund_processed_amount.rs b/crates/analytics/src/refunds/metrics/refund_processed_amount.rs index 6cba5f58fed5..1aa74b85a043 100644 --- a/crates/analytics/src/refunds/metrics/refund_processed_amount.rs +++ b/crates/analytics/src/refunds/metrics/refund_processed_amount.rs @@ -33,7 +33,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -80,7 +80,7 @@ where } query_builder.add_group_by_clause("currency").switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/refunds/metrics/refund_success_count.rs b/crates/analytics/src/refunds/metrics/refund_success_count.rs index 642cf70580d4..0448fbfd65c7 100644 --- a/crates/analytics/src/refunds/metrics/refund_success_count.rs +++ b/crates/analytics/src/refunds/metrics/refund_success_count.rs @@ -34,7 +34,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -76,7 +76,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/refunds/metrics/refund_success_rate.rs b/crates/analytics/src/refunds/metrics/refund_success_rate.rs index 7b5716ba41a1..09f68fb613ec 100644 --- a/crates/analytics/src/refunds/metrics/refund_success_rate.rs +++ b/crates/analytics/src/refunds/metrics/refund_success_rate.rs @@ -32,7 +32,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -77,7 +77,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_count.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_count.rs index c77e1f7a52c1..cce27c9e6f88 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_count.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_count.rs @@ -33,7 +33,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -79,7 +79,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_processed_amount.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_processed_amount.rs index c91938228af1..b80c031e6553 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_processed_amount.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_processed_amount.rs @@ -33,7 +33,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -82,7 +82,7 @@ where query_builder.add_group_by_clause("currency").switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_count.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_count.rs index 332261a32083..a7e7b8fae9e4 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_count.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_count.rs @@ -34,7 +34,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -76,7 +76,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_rate.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_rate.rs index 35ee0d61b509..701edeb65bb6 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_rate.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_success_rate.rs @@ -32,7 +32,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> @@ -77,7 +77,7 @@ where query_builder.add_group_by_clause(dim).switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut query_builder) .switch()?; diff --git a/crates/analytics/src/sdk_events/core.rs b/crates/analytics/src/sdk_events/core.rs index 3eca479818b2..c8ea156674a2 100644 --- a/crates/analytics/src/sdk_events/core.rs +++ b/crates/analytics/src/sdk_events/core.rs @@ -65,7 +65,7 @@ pub async fn get_metrics( &req.group_by_names.clone(), &publishable_key_scoped, &req.filters, - &req.time_series.map(|t| t.granularity), + req.time_series.map(|t| t.granularity), &req.time_range, ) .await diff --git a/crates/analytics/src/sdk_events/metrics.rs b/crates/analytics/src/sdk_events/metrics.rs index 7d5ad0c53d48..3c587925a2fc 100644 --- a/crates/analytics/src/sdk_events/metrics.rs +++ b/crates/analytics/src/sdk_events/metrics.rs @@ -56,7 +56,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult>; @@ -77,7 +77,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { diff --git a/crates/analytics/src/sdk_events/metrics/average_payment_time.rs b/crates/analytics/src/sdk_events/metrics/average_payment_time.rs index c7f6bca988c7..1b3ce5668270 100644 --- a/crates/analytics/src/sdk_events/metrics/average_payment_time.rs +++ b/crates/analytics/src/sdk_events/metrics/average_payment_time.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -54,7 +54,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/load_time.rs b/crates/analytics/src/sdk_events/metrics/load_time.rs index 73cc693c5064..6c6ce21a75e5 100644 --- a/crates/analytics/src/sdk_events/metrics/load_time.rs +++ b/crates/analytics/src/sdk_events/metrics/load_time.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -54,7 +54,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/payment_attempts.rs b/crates/analytics/src/sdk_events/metrics/payment_attempts.rs index 4d949d9fb822..a7bb717102f5 100644 --- a/crates/analytics/src/sdk_events/metrics/payment_attempts.rs +++ b/crates/analytics/src/sdk_events/metrics/payment_attempts.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/payment_data_filled_count.rs b/crates/analytics/src/sdk_events/metrics/payment_data_filled_count.rs index 37eb967b385b..0488907f9a77 100644 --- a/crates/analytics/src/sdk_events/metrics/payment_data_filled_count.rs +++ b/crates/analytics/src/sdk_events/metrics/payment_data_filled_count.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/payment_method_selected_count.rs b/crates/analytics/src/sdk_events/metrics/payment_method_selected_count.rs index d524d0021cf5..9599caa1e7b7 100644 --- a/crates/analytics/src/sdk_events/metrics/payment_method_selected_count.rs +++ b/crates/analytics/src/sdk_events/metrics/payment_method_selected_count.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/payment_methods_call_count.rs b/crates/analytics/src/sdk_events/metrics/payment_methods_call_count.rs index 081c4968c533..77e6f3899305 100644 --- a/crates/analytics/src/sdk_events/metrics/payment_methods_call_count.rs +++ b/crates/analytics/src/sdk_events/metrics/payment_methods_call_count.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs b/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs index 92308acac692..25c81eacd806 100644 --- a/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs +++ b/crates/analytics/src/sdk_events/metrics/sdk_initiated_count.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/analytics/src/sdk_events/metrics/sdk_rendered_count.rs b/crates/analytics/src/sdk_events/metrics/sdk_rendered_count.rs index 6f03008e0c19..e972abbd8e36 100644 --- a/crates/analytics/src/sdk_events/metrics/sdk_rendered_count.rs +++ b/crates/analytics/src/sdk_events/metrics/sdk_rendered_count.rs @@ -34,7 +34,7 @@ where dimensions: &[SdkEventDimensions], publishable_key: &str, filters: &SdkEventFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -53,7 +53,7 @@ where }) .switch()?; - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { query_builder .add_granularity_in_mins(granularity) .switch()?; diff --git a/crates/api_models/src/connector_enums.rs b/crates/api_models/src/connector_enums.rs index 4931b8dbd922..294666f35f80 100644 --- a/crates/api_models/src/connector_enums.rs +++ b/crates/api_models/src/connector_enums.rs @@ -139,7 +139,7 @@ pub enum Connector { impl Connector { #[cfg(feature = "payouts")] - pub fn supports_instant_payout(&self, payout_method: Option) -> bool { + pub fn supports_instant_payout(self, payout_method: Option) -> bool { matches!( (self, payout_method), (Self::Paypal, Some(PayoutType::Wallet)) @@ -148,26 +148,26 @@ impl Connector { ) } #[cfg(feature = "payouts")] - pub fn supports_create_recipient(&self, payout_method: Option) -> bool { + pub fn supports_create_recipient(self, payout_method: Option) -> bool { matches!((self, payout_method), (_, Some(PayoutType::Bank))) } #[cfg(feature = "payouts")] - pub fn supports_payout_eligibility(&self, payout_method: Option) -> bool { + pub fn supports_payout_eligibility(self, payout_method: Option) -> bool { matches!((self, payout_method), (_, Some(PayoutType::Card))) } #[cfg(feature = "payouts")] - pub fn is_payout_quote_call_required(&self) -> bool { + pub fn is_payout_quote_call_required(self) -> bool { matches!(self, Self::Wise) } #[cfg(feature = "payouts")] - pub fn supports_access_token_for_payout(&self, payout_method: Option) -> bool { + pub fn supports_access_token_for_payout(self, payout_method: Option) -> bool { matches!((self, payout_method), (Self::Paypal, _)) } #[cfg(feature = "payouts")] - pub fn supports_vendor_disburse_account_create_for_payout(&self) -> bool { + pub fn supports_vendor_disburse_account_create_for_payout(self) -> bool { matches!(self, Self::Stripe) } - pub fn supports_access_token(&self, payment_method: PaymentMethod) -> bool { + pub fn supports_access_token(self, payment_method: PaymentMethod) -> bool { matches!( (self, payment_method), (Self::Airwallex, _) @@ -181,13 +181,13 @@ impl Connector { | (Self::Itaubank, _) ) } - pub fn supports_file_storage_module(&self) -> bool { + pub fn supports_file_storage_module(self) -> bool { matches!(self, Self::Stripe | Self::Checkout) } - pub fn requires_defend_dispute(&self) -> bool { + pub fn requires_defend_dispute(self) -> bool { matches!(self, Self::Checkout) } - pub fn is_separate_authentication_supported(&self) -> bool { + pub fn is_separate_authentication_supported(self) -> bool { match self { #[cfg(feature = "dummy_connector")] Self::DummyConnector1 @@ -281,15 +281,15 @@ impl Connector { Self::Checkout | Self::Nmi | Self::Cybersource => true, } } - pub fn is_pre_processing_required_before_authorize(&self) -> bool { + pub fn is_pre_processing_required_before_authorize(self) -> bool { matches!(self, Self::Airwallex) } - pub fn should_acknowledge_webhook_for_resource_not_found_errors(&self) -> bool { + pub fn should_acknowledge_webhook_for_resource_not_found_errors(self) -> bool { matches!(self, Self::Adyenplatform) } #[cfg(feature = "dummy_connector")] pub fn validate_dummy_connector_enabled( - &self, + self, is_dummy_connector_enabled: bool, ) -> errors::CustomResult<(), errors::ValidationError> { if !is_dummy_connector_enabled diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 781b5e3710a7..385d023b9c1e 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -597,13 +597,13 @@ pub enum Currency { impl Currency { /// Convert the amount to its base denomination based on Currency and return String - pub fn to_currency_base_unit(&self, amount: i64) -> Result { + pub fn to_currency_base_unit(self, amount: i64) -> Result { let amount_f64 = self.to_currency_base_unit_asf64(amount)?; Ok(format!("{amount_f64:.2}")) } /// Convert the amount to its base denomination based on Currency and return f64 - pub fn to_currency_base_unit_asf64(&self, amount: i64) -> Result { + pub fn to_currency_base_unit_asf64(self, amount: i64) -> Result { let amount_f64: f64 = u32::try_from(amount)?.into(); let amount = if self.is_zero_decimal_currency() { amount_f64 @@ -616,7 +616,7 @@ impl Currency { } ///Convert the higher decimal amount to its base absolute units - pub fn to_currency_lower_unit(&self, amount: String) -> Result { + pub fn to_currency_lower_unit(self, amount: String) -> Result { let amount_f64 = amount.parse::()?; let amount_string = if self.is_zero_decimal_currency() { amount_f64 @@ -632,7 +632,7 @@ impl Currency { /// Paypal Connector accepts Zero and Two decimal currency but not three decimal and it should be updated as required for 3 decimal currencies. /// Paypal Ref - https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/ pub fn to_currency_base_unit_with_zero_decimal_check( - &self, + self, amount: i64, ) -> Result { let amount_f64 = self.to_currency_base_unit_asf64(amount)?; @@ -643,8 +643,8 @@ impl Currency { } } - pub fn iso_4217(&self) -> &'static str { - match *self { + pub fn iso_4217(self) -> &'static str { + match self { Self::AED => "784", Self::AFN => "971", Self::ALL => "008", @@ -1299,7 +1299,7 @@ pub enum IntentStatus { impl IntentStatus { /// Indicates whether the syncing with the connector should be allowed or not - pub fn should_force_sync_with_connector(&self) -> bool { + pub fn should_force_sync_with_connector(self) -> bool { match self { // Confirm has not happened yet Self::RequiresConfirmation @@ -2493,7 +2493,7 @@ pub enum ClientPlatform { } impl PaymentSource { - pub fn is_for_internal_use_only(&self) -> bool { + pub fn is_for_internal_use_only(self) -> bool { match self { Self::Dashboard | Self::Sdk | Self::MerchantServer | Self::Postman => false, Self::Webhook | Self::ExternalAuthenticator => true, @@ -2588,7 +2588,7 @@ pub enum AuthenticationConnectors { } impl AuthenticationConnectors { - pub fn is_separate_version_call_required(&self) -> bool { + pub fn is_separate_version_call_required(self) -> bool { match self { Self::Threedsecureio | Self::Netcetera => false, Self::Gpayments => true, @@ -2622,15 +2622,15 @@ pub enum AuthenticationStatus { } impl AuthenticationStatus { - pub fn is_terminal_status(&self) -> bool { + pub fn is_terminal_status(self) -> bool { match self { Self::Started | Self::Pending => false, Self::Success | Self::Failed => true, } } - pub fn is_failed(&self) -> bool { - self == &Self::Failed + pub fn is_failed(self) -> bool { + self == Self::Failed } } diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs index ddf55d293719..ad0d4ecfe93c 100644 --- a/crates/common_enums/src/transformers.rs +++ b/crates/common_enums/src/transformers.rs @@ -522,7 +522,7 @@ impl Country { CountryAlpha2::ZW => Self::Zimbabwe, } } - pub const fn to_alpha2(&self) -> CountryAlpha2 { + pub const fn to_alpha2(self) -> CountryAlpha2 { match self { Self::Afghanistan => CountryAlpha2::AF, Self::AlandIslands => CountryAlpha2::AX, @@ -1028,7 +1028,7 @@ impl Country { CountryAlpha3::ZWE => Self::Zimbabwe, } } - pub const fn to_alpha3(&self) -> CountryAlpha3 { + pub const fn to_alpha3(self) -> CountryAlpha3 { match self { Self::Afghanistan => CountryAlpha3::AFG, Self::AlandIslands => CountryAlpha3::ALA, @@ -1535,7 +1535,7 @@ impl Country { _ => Err(NumericCountryCodeParseError), } } - pub const fn to_numeric(&self) -> u32 { + pub const fn to_numeric(self) -> u32 { match self { Self::Afghanistan => 4, Self::AlandIslands => 248, @@ -1905,6 +1905,10 @@ mod custom_serde { use super::*; + #[allow( + clippy::trivially_copy_pass_by_ref, + reason = "`serde::Serialize` needs it to accept `&Country`" + )] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, @@ -1937,6 +1941,10 @@ mod custom_serde { use super::*; + #[allow( + clippy::trivially_copy_pass_by_ref, + reason = "`serde::Serialize` needs it to accept `&Country`" + )] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, @@ -1969,6 +1977,10 @@ mod custom_serde { use super::*; + #[allow( + clippy::trivially_copy_pass_by_ref, + reason = "`serde::Serialize` needs it to accept `&Country`" + )] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, diff --git a/crates/common_utils/src/id_type.rs b/crates/common_utils/src/id_type.rs index a8085564145c..e0aa77ce707e 100644 --- a/crates/common_utils/src/id_type.rs +++ b/crates/common_utils/src/id_type.rs @@ -47,7 +47,7 @@ use thiserror::Error; use crate::{fp_utils::when, generate_id_with_default_len}; #[inline] -fn is_valid_id_character(input_char: &char) -> bool { +fn is_valid_id_character(input_char: char) -> bool { input_char.is_ascii_alphanumeric() || matches!(input_char, '_' | '-') } @@ -57,7 +57,7 @@ fn get_invalid_input_character(input_string: Cow<'static, str>) -> Option input_string .trim() .chars() - .find(|char| !is_valid_id_character(char)) + .find(|&char| !is_valid_id_character(char)) } #[derive(Debug, PartialEq, Hash, Serialize, Clone, Eq)] diff --git a/crates/common_utils/src/id_type/global_id.rs b/crates/common_utils/src/id_type/global_id.rs index a54df7585870..d783912459e8 100644 --- a/crates/common_utils/src/id_type/global_id.rs +++ b/crates/common_utils/src/id_type/global_id.rs @@ -29,7 +29,7 @@ pub(crate) enum GlobalEntity { } impl GlobalEntity { - fn prefix(&self) -> &'static str { + fn prefix(self) -> &'static str { match self { Self::Customer => "cus", Self::Payment => "pay", diff --git a/crates/common_utils/src/types.rs b/crates/common_utils/src/types.rs index 1e547a497135..2328b905514c 100644 --- a/crates/common_utils/src/types.rs +++ b/crates/common_utils/src/types.rs @@ -375,7 +375,7 @@ pub struct MinorUnit(i64); impl MinorUnit { /// gets amount as i64 value will be removed in future - pub fn get_amount_as_i64(&self) -> i64 { + pub fn get_amount_as_i64(self) -> i64 { self.0 } diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index 1ee6f10c6350..e05e8a28dbf6 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -64,7 +64,7 @@ impl api::RefundExecute for Cashtocode {} impl api::RefundSync for Cashtocode {} fn get_b64_auth_cashtocode( - payment_method_type: &Option, + payment_method_type: Option, auth_type: &transformers::CashtocodeAuth, ) -> CustomResult)>, errors::ConnectorError> { fn construct_basic_auth( @@ -202,7 +202,7 @@ impl ConnectorIntegration CustomResult { match payment_method_type { @@ -260,7 +260,6 @@ impl .data .request .payment_method_type - .as_ref() .ok_or(errors::ConnectorError::MissingPaymentMethodType)?; let redirection_data = get_redirect_form_data(payment_method_type, response_data)?; ( diff --git a/crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs b/crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs index 74c8d1edb381..83f861dfdb35 100644 --- a/crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/powertranz/transformers.rs @@ -1,4 +1,4 @@ -use common_enums::enums::{self, AuthenticationType, Currency}; +use common_enums::enums::{self, AuthenticationType}; use common_utils::pii::IpAddress; use hyperswitch_domain_models::{ payment_method_data::{Card, PaymentMethodData}, @@ -148,7 +148,7 @@ impl TryFrom<&PaymentsAuthorizeRouterData> for PowertranzPaymentsRequest { item.request.amount, item.request.currency, )?, - currency_code: Currency::iso_4217(&item.request.currency).to_string(), + currency_code: item.request.currency.iso_4217().to_string(), three_d_secure, source, order_identifier: item.connector_request_reference_id.clone(), diff --git a/crates/hyperswitch_connectors/src/connectors/worldline.rs b/crates/hyperswitch_connectors/src/connectors/worldline.rs index e40d48172243..3d2335ad0c7b 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline.rs @@ -62,7 +62,7 @@ impl Worldline { pub fn generate_authorization_token( &self, auth: worldline::WorldlineAuthType, - http_method: &Method, + http_method: Method, content_type: &str, date: &str, endpoint: &str, @@ -113,7 +113,7 @@ where let date = Self::get_current_date_time()?; let content_type = Self::get_content_type(self); let signed_data: String = - self.generate_authorization_token(auth, &http_method, content_type, &date, &endpoint)?; + self.generate_authorization_token(auth, http_method, content_type, &date, &endpoint)?; Ok(vec![ (headers::DATE.to_string(), date.into()), diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rs index e35c46723086..c65ec864d321 100644 --- a/crates/kgraph_utils/src/mca.rs +++ b/crates/kgraph_utils/src/mca.rs @@ -515,13 +515,13 @@ fn compile_graph_for_countries_and_currencies( fn compile_config_graph( builder: &mut cgraph::ConstraintGraphBuilder, config: &kgraph_types::CountryCurrencyFilter, - connector: &api_enums::RoutableConnectors, + connector: api_enums::RoutableConnectors, ) -> Result { let mut agg_node_id: Vec<(cgraph::NodeId, cgraph::Relation, cgraph::Strength)> = Vec::new(); let mut pmt_enabled: Vec = Vec::new(); if let Some(pmt) = config .connector_configs - .get(connector) + .get(&connector) .or(config.default_configs.as_ref()) .map(|inner| inner.0.clone()) { @@ -635,7 +635,7 @@ fn compile_merchant_connector_graph( let config_info = "Config for respective PaymentMethodType for the connector"; - let config_enabled_agg_id = compile_config_graph(builder, config, &connector)?; + let config_enabled_agg_id = compile_config_graph(builder, config, connector)?; let domain_level_node_id = builder .make_all_aggregator( diff --git a/crates/router/src/bin/router.rs b/crates/router/src/bin/router.rs index 5b6dd81501b8..212a12574252 100644 --- a/crates/router/src/bin/router.rs +++ b/crates/router/src/bin/router.rs @@ -35,7 +35,7 @@ async fn main() -> ApplicationResult<()> { // Spawn a thread for collecting metrics at fixed intervals metrics::bg_metrics_collector::spawn_metrics_collector( - &conf.log.telemetry.bg_metrics_collection_interval_in_secs, + conf.log.telemetry.bg_metrics_collection_interval_in_secs, ); #[allow(clippy::expect_used)] diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs index 7daee6e73d74..ebc094a862cc 100644 --- a/crates/router/src/connector/adyen/transformers.rs +++ b/crates/router/src/connector/adyen/transformers.rs @@ -1738,7 +1738,7 @@ fn get_additional_data(item: &types::PaymentsAuthorizeRouterData) -> Option) -> Option { +fn get_channel_type(pm_type: Option) -> Option { pm_type.as_ref().and_then(|pmt| match pmt { storage_enums::PaymentMethodType::GoPay | storage_enums::PaymentMethodType::Vipps => { Some(Channel::Web) @@ -3135,7 +3135,7 @@ impl let additional_data = get_additional_data(item.router_data); let payment_method = AdyenPaymentMethod::try_from((wallet_data, item.router_data))?; let shopper_interaction = AdyenShopperInteraction::from(item.router_data); - let channel = get_channel_type(&item.router_data.request.payment_method_type); + let channel = get_channel_type(item.router_data.request.payment_method_type); let (recurring_processing_model, store_payment_method, shopper_reference) = get_recurring_processing_model(item.router_data)?; let return_url = item.router_data.request.get_router_return_url()?; diff --git a/crates/router/src/connector/paybox/transformers.rs b/crates/router/src/connector/paybox/transformers.rs index 27096c2a63b5..c36b0d90af8e 100644 --- a/crates/router/src/connector/paybox/transformers.rs +++ b/crates/router/src/connector/paybox/transformers.rs @@ -189,8 +189,7 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsCaptureRouterData>> for PayboxCap let auth_data: PayboxAuthType = PayboxAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; - let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) - .to_string(); + let currency = item.router_data.request.currency.iso_4217().to_string(); let paybox_meta_data: PayboxMeta = utils::to_connector_meta(item.router_data.request.connector_meta.clone())?; let format_time = common_utils::date_time::format_date( @@ -387,9 +386,7 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsAuthorizeRouterData>> for PayboxP item.router_data.request.capture_method, item.router_data.request.is_mandate_payment(), )?; - let currency = - diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) - .to_string(); + let currency = item.router_data.request.currency.iso_4217().to_string(); let expiration_date = req_card.get_card_expiry_month_year_2_digit_with_delimiter("".to_owned())?; let format_time = common_utils::date_time::format_date( @@ -884,8 +881,7 @@ impl TryFrom<&PayboxRouterData<&types::RefundsRouterData>> for PayboxRefun let auth_data: PayboxAuthType = PayboxAuthType::try_from(&item.router_data.connector_auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; - let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) - .to_string(); + let currency = item.router_data.request.currency.iso_4217().to_string(); let format_time = common_utils::date_time::format_date( common_utils::date_time::now(), DateFormat::DDMMYYYYHHmmss, @@ -1079,9 +1075,7 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsCompleteAuthorizeRouterData>> for item.router_data.request.capture_method, item.router_data.request.is_mandate_payment(), )?; - let currency = - diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) - .to_string(); + let currency = item.router_data.request.currency.iso_4217().to_string(); let expiration_date = req_card.get_card_expiry_month_year_2_digit_with_delimiter("".to_owned())?; let format_time = common_utils::date_time::format_date( @@ -1196,8 +1190,7 @@ impl Some(enums::CaptureMethod::Manual) => Ok(MANDATE_AUTH_ONLY.to_string()), _ => Err(errors::ConnectorError::CaptureMethodNotSupported), }?; - let currency = diesel_models::enums::Currency::iso_4217(&item.router_data.request.currency) - .to_string(); + let currency = item.router_data.request.currency.iso_4217().to_string(); let format_time = common_utils::date_time::format_date( common_utils::date_time::now(), DateFormat::DDMMYYYYHHmmss, diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index 64c3fcdf5a1b..49a1de382f27 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -53,7 +53,7 @@ impl Rapyd { http_method: &str, url_path: &str, body: &str, - timestamp: &i64, + timestamp: i64, salt: &str, ) -> CustomResult { let rapyd::RapydAuthType { @@ -233,7 +233,7 @@ impl let body = types::PaymentsAuthorizeType::get_request_body(self, req, connectors)?; let req_body = body.get_inner_value().expose(); let signature = - self.generate_signature(&auth, "post", "/v1/payments", &req_body, ×tamp, &salt)?; + self.generate_signature(&auth, "post", "/v1/payments", &req_body, timestamp, &salt)?; let headers = vec![ ("access_key".to_string(), auth.access_key.into_masked()), ("salt".to_string(), salt.into_masked()), @@ -361,7 +361,7 @@ impl let auth: rapyd::RapydAuthType = rapyd::RapydAuthType::try_from(&req.connector_auth_type)?; let url_path = format!("/v1/payments/{}", req.request.connector_transaction_id); let signature = - self.generate_signature(&auth, "delete", &url_path, "", ×tamp, &salt)?; + self.generate_signature(&auth, "delete", &url_path, "", timestamp, &salt)?; let headers = vec![ ("access_key".to_string(), auth.access_key.into_masked()), @@ -460,7 +460,7 @@ impl .get_connector_transaction_id() .change_context(errors::ConnectorError::MissingConnectorTransactionID)? ); - let signature = self.generate_signature(&auth, "get", &url_path, "", ×tamp, &salt)?; + let signature = self.generate_signature(&auth, "get", &url_path, "", timestamp, &salt)?; let headers = vec![ ("access_key".to_string(), auth.access_key.into_masked()), @@ -563,7 +563,7 @@ impl let body = types::PaymentsCaptureType::get_request_body(self, req, connectors)?; let req_body = body.get_inner_value().expose(); let signature = - self.generate_signature(&auth, "post", &url_path, &req_body, ×tamp, &salt)?; + self.generate_signature(&auth, "post", &url_path, &req_body, timestamp, &salt)?; let headers = vec![ ("access_key".to_string(), auth.access_key.into_masked()), ("salt".to_string(), salt.into_masked()), @@ -700,7 +700,7 @@ impl services::ConnectorIntegration String { } fn check_payment_link_invalid_conditions( - intent_status: &storage_enums::IntentStatus, + intent_status: storage_enums::IntentStatus, not_allowed_statuses: &[storage_enums::IntentStatus], ) -> bool { - not_allowed_statuses.contains(intent_status) + not_allowed_statuses.contains(&intent_status) } #[cfg(feature = "v2")] diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index 599d696ec06d..e68927b75397 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -433,7 +433,7 @@ pub async fn render_pm_collect_link( fn generate_task_id_for_payment_method_status_update_workflow( key_id: &str, - runner: &storage::ProcessTrackerRunner, + runner: storage::ProcessTrackerRunner, task: &str, ) -> String { format!("{runner}_{task}_{key_id}") @@ -467,7 +467,7 @@ pub async fn add_payment_method_status_update_task( let process_tracker_id = generate_task_id_for_payment_method_status_update_workflow( payment_method.get_id().as_str(), - &runner, + runner, task, ); let process_tracker_entry = storage::ProcessTrackerNew::new( diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index ad612ed6f3be..68b1790880dd 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -3328,7 +3328,7 @@ pub async fn list_payment_methods( None }; - helpers::infer_payment_type(&amount, mandate_type.as_ref()) + helpers::infer_payment_type(amount, mandate_type.as_ref()) }); let all_mcas = db @@ -3838,7 +3838,7 @@ pub async fn list_payment_methods( .extend(required_fields_final.non_mandate.clone()); } required_fields_hs = should_collect_shipping_or_billing_details_from_wallet_connector( - &payment_method, + payment_method, element.payment_experience.as_ref(), business_profile.as_ref(), required_fields_hs.clone(), @@ -4269,7 +4269,7 @@ pub async fn list_payment_methods( } fn should_collect_shipping_or_billing_details_from_wallet_connector( - payment_method: &api_enums::PaymentMethod, + payment_method: api_enums::PaymentMethod, payment_experience_optional: Option<&api_enums::PaymentExperience>, business_profile: Option<&Profile>, mut required_fields_hs: HashMap, @@ -4553,7 +4553,7 @@ pub async fn filter_payment_methods( let filter_pm_based_on_allowed_types = filter_pm_based_on_allowed_types( allowed_payment_method_types.as_ref(), - &payment_method_object.payment_method_type, + payment_method_object.payment_method_type, ); if payment_attempt @@ -4596,7 +4596,7 @@ pub async fn filter_payment_methods( let filter_pm_card_network_based = filter_pm_card_network_based( payment_method_object.card_networks.as_ref(), req.card_networks.as_ref(), - &payment_method_object.payment_method_type, + payment_method_object.payment_method_type, ); let saved_payment_methods_filter = req @@ -4696,7 +4696,7 @@ fn filter_installment_based( fn filter_pm_card_network_based( pm_card_networks: Option<&Vec>, request_card_networks: Option<&Vec>, - pm_type: &api_enums::PaymentMethodType, + pm_type: api_enums::PaymentMethodType, ) -> bool { match pm_type { api_enums::PaymentMethodType::Credit | api_enums::PaymentMethodType::Debit => { @@ -4714,9 +4714,9 @@ fn filter_pm_card_network_based( fn filter_pm_based_on_allowed_types( allowed_types: Option<&Vec>, - payment_method_type: &api_enums::PaymentMethodType, + payment_method_type: api_enums::PaymentMethodType, ) -> bool { - allowed_types.map_or(true, |pm| pm.contains(payment_method_type)) + allowed_types.map_or(true, |pm| pm.contains(&payment_method_type)) } fn filter_recurring_based( diff --git a/crates/router/src/core/payment_methods/utils.rs b/crates/router/src/core/payment_methods/utils.rs index 604e8c706262..816807fe0149 100644 --- a/crates/router/src/core/payment_methods/utils.rs +++ b/crates/router/src/core/payment_methods/utils.rs @@ -96,7 +96,7 @@ fn compile_pm_graph( domain_id, supported_payment_methods_for_update_mandate, pmt.clone(), - &pm_enabled.payment_method, + pm_enabled.payment_method, ); if let Ok(Some(connector_eligible_for_update_mandates_node)) = res { agg_or_nodes_for_mandate_filters.push(( @@ -200,7 +200,7 @@ fn compile_pm_graph( .or_else(|| config.0.get("default")) .map(|inner| { if let Ok(Some(capture_method_filter)) = - construct_capture_method_node(builder, inner, &pmt.payment_method_type) + construct_capture_method_node(builder, inner, pmt.payment_method_type) { agg_nodes.push(( capture_method_filter, @@ -214,7 +214,7 @@ fn compile_pm_graph( if let Ok(Some(country_node)) = compile_accepted_countries_for_mca( builder, domain_id, - &pmt.payment_method_type, + pmt.payment_method_type, pmt.accepted_countries, config, connector.clone(), @@ -230,7 +230,7 @@ fn compile_pm_graph( if let Ok(Some(currency_node)) = compile_accepted_currency_for_mca( builder, domain_id, - &pmt.payment_method_type, + pmt.payment_method_type, pmt.accepted_currencies, config, connector.clone(), @@ -274,7 +274,7 @@ fn construct_supported_connectors_for_update_mandate_node( domain_id: cgraph::DomainId, supported_payment_methods_for_update_mandate: &settings::SupportedPaymentMethodsForMandate, pmt: RequestPaymentMethodTypes, - payment_method: &enums::PaymentMethod, + payment_method: enums::PaymentMethod, ) -> Result, KgraphError> { let card_value_node = builder.make_value_node( cgraph::NodeValue::Value(dir::DirValue::PaymentMethod(enums::PaymentMethod::Card)), @@ -296,9 +296,9 @@ fn construct_supported_connectors_for_update_mandate_node( if let Some(supported_pm_for_mandates) = supported_payment_methods_for_update_mandate .0 - .get(payment_method) + .get(&payment_method) { - if payment_method == &enums::PaymentMethod::Card { + if payment_method == enums::PaymentMethod::Card { if let Some(credit_connector_list) = supported_pm_for_mandates .0 .get(&api_enums::PaymentMethodType::Credit) @@ -498,12 +498,12 @@ fn construct_supported_connectors_for_mandate_node( fn construct_capture_method_node( builder: &mut cgraph::ConstraintGraphBuilder, payment_method_filters: &settings::PaymentMethodFilters, - payment_method_type: &api_enums::PaymentMethodType, + payment_method_type: api_enums::PaymentMethodType, ) -> Result, KgraphError> { if !payment_method_filters .0 .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - *payment_method_type, + payment_method_type, )) .and_then(|v| v.not_available_flows) .and_then(|v| v.capture_method) @@ -542,7 +542,7 @@ fn construct_capture_method_node( fn compile_accepted_countries_for_mca( builder: &mut cgraph::ConstraintGraphBuilder, domain_id: cgraph::DomainId, - payment_method_type: &enums::PaymentMethodType, + payment_method_type: enums::PaymentMethodType, pm_countries: Option, config: &settings::ConnectorFilters, connector: String, @@ -608,7 +608,7 @@ fn compile_accepted_countries_for_mca( derived_config .0 .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - *payment_method_type, + payment_method_type, )) { if let Some(config_countries) = value.country.as_ref() { @@ -636,7 +636,7 @@ fn compile_accepted_countries_for_mca( default_derived_config .0 .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - *payment_method_type, + payment_method_type, )) { if let Some(config_countries) = value.country.as_ref() { @@ -673,7 +673,7 @@ fn compile_accepted_countries_for_mca( fn compile_accepted_currency_for_mca( builder: &mut cgraph::ConstraintGraphBuilder, domain_id: cgraph::DomainId, - payment_method_type: &enums::PaymentMethodType, + payment_method_type: enums::PaymentMethodType, pm_currency: Option, config: &settings::ConnectorFilters, connector: String, @@ -730,7 +730,7 @@ fn compile_accepted_currency_for_mca( derived_config .0 .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - *payment_method_type, + payment_method_type, )) { if let Some(config_currencies) = value.currency.as_ref() { @@ -760,7 +760,7 @@ fn compile_accepted_currency_for_mca( default_derived_config .0 .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - *payment_method_type, + payment_method_type, )) { if let Some(config_currencies) = value.currency.as_ref() { diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs index 7a24f2a30a2c..e4f72c717f6c 100644 --- a/crates/router/src/core/payment_methods/vault.rs +++ b/crates/router/src/core/payment_methods/vault.rs @@ -1379,7 +1379,7 @@ pub async fn add_delete_tokenized_data_task( lookup_key: lookup_key.to_owned(), pm, }; - let schedule_time = get_delete_tokenize_schedule_time(db, &pm, 0) + let schedule_time = get_delete_tokenize_schedule_time(db, pm, 0) .await .ok_or(errors::ApiErrorResponse::InternalServerError) .attach_printable("Failed to obtain initial process tracker schedule time")?; @@ -1434,8 +1434,7 @@ pub async fn start_tokenize_data_workflow( } Err(err) => { logger::error!("Err: Deleting Card From Locker : {:?}", err); - retry_delete_tokenize(db, &delete_tokenize_data.pm, tokenize_tracker.to_owned()) - .await?; + retry_delete_tokenize(db, delete_tokenize_data.pm, tokenize_tracker.to_owned()).await?; metrics::RETRIED_DELETE_DATA_COUNT.add(&metrics::CONTEXT, 1, &[]); } } @@ -1444,7 +1443,7 @@ pub async fn start_tokenize_data_workflow( pub async fn get_delete_tokenize_schedule_time( db: &dyn db::StorageInterface, - pm: &enums::PaymentMethod, + pm: enums::PaymentMethod, retry_count: i32, ) -> Option { let redis_mapping = db::get_and_deserialize_key( @@ -1467,7 +1466,7 @@ pub async fn get_delete_tokenize_schedule_time( pub async fn retry_delete_tokenize( db: &dyn db::StorageInterface, - pm: &enums::PaymentMethod, + pm: enums::PaymentMethod, pt: storage::ProcessTracker, ) -> Result<(), errors::ProcessTrackerError> { let schedule_time = get_delete_tokenize_schedule_time(db, pm, pt.retry_count).await; diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index 684293151ed5..fb887c4bc761 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -3277,8 +3277,8 @@ where payment_data.set_surcharge_details(session_surcharge_details.as_ref().and_then( |session_surcharge_details| { session_surcharge_details.fetch_surcharge_details( - &session_connector_data.payment_method_type.into(), - &session_connector_data.payment_method_type, + session_connector_data.payment_method_type.into(), + session_connector_data.payment_method_type, None, ) }, @@ -3732,8 +3732,8 @@ where fn is_payment_method_tokenization_enabled_for_connector( state: &SessionState, connector_name: &str, - payment_method: &storage::enums::PaymentMethod, - payment_method_type: &Option, + payment_method: storage::enums::PaymentMethod, + payment_method_type: Option, apple_pay_flow: &Option, ) -> RouterResult { let connector_tokenization_filter = state.conf.tokenization.0.get(connector_name); @@ -3743,7 +3743,7 @@ fn is_payment_method_tokenization_enabled_for_connector( connector_filter .payment_method .clone() - .contains(payment_method) + .contains(&payment_method) && is_payment_method_type_allowed_for_connector( payment_method_type, connector_filter.payment_method_type.clone(), @@ -3758,7 +3758,7 @@ fn is_payment_method_tokenization_enabled_for_connector( } fn is_apple_pay_pre_decrypt_type_connector_tokenization( - payment_method_type: &Option, + payment_method_type: Option, apple_pay_flow: &Option, apple_pay_pre_decrypt_flow_filter: Option, ) -> bool { @@ -3776,7 +3776,7 @@ fn is_apple_pay_pre_decrypt_type_connector_tokenization( fn decide_apple_pay_flow( state: &SessionState, - payment_method_type: &Option, + payment_method_type: Option, merchant_connector_account: Option<&helpers::MerchantConnectorAccountType>, ) -> Option { payment_method_type.and_then(|pmt| match pmt { @@ -3868,10 +3868,10 @@ fn check_apple_pay_metadata( } fn is_payment_method_type_allowed_for_connector( - current_pm_type: &Option, + current_pm_type: Option, pm_type_filter: Option, ) -> bool { - match (*current_pm_type).zip(pm_type_filter) { + match (current_pm_type).zip(pm_type_filter) { Some((pm_type, type_filter)) => match type_filter { PaymentMethodTypeTokenFilter::AllAccepted => true, PaymentMethodTypeTokenFilter::EnableOnly(enabled) => enabled.contains(&pm_type), @@ -3884,7 +3884,7 @@ fn is_payment_method_type_allowed_for_connector( async fn decide_payment_method_tokenize_action( state: &SessionState, connector_name: &str, - payment_method: &storage::enums::PaymentMethod, + payment_method: storage::enums::PaymentMethod, pm_parent_token: Option<&str>, is_connector_tokenization_enabled: bool, apple_pay_flow: Option, @@ -4037,11 +4037,11 @@ where TokenizationAction::SkipConnectorTokenization, ), Some(connector) if is_operation_confirm(&operation) => { - let payment_method = &payment_data + let payment_method = payment_data .get_payment_attempt() .payment_method .get_required_value("payment_method")?; - let payment_method_type = &payment_data.get_payment_attempt().payment_method_type; + let payment_method_type = payment_data.get_payment_attempt().payment_method_type; let apple_pay_flow = decide_apple_pay_flow(state, payment_method_type, Some(merchant_connector_account)); @@ -4068,7 +4068,7 @@ where payment_data.get_token(), is_connector_tokenization_enabled, apple_pay_flow, - *payment_method_type, + payment_method_type, ) .await?; @@ -6236,7 +6236,7 @@ pub async fn payment_external_authentication( })? } helpers::validate_payment_status_against_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[storage_enums::IntentStatus::RequiresCustomerAction], "authenticate", )?; diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index 265046f42d96..71049a56241d 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -162,7 +162,7 @@ fn is_dynamic_fields_required( required_fields: &settings::RequiredFields, payment_method: enums::PaymentMethod, payment_method_type: enums::PaymentMethodType, - connector: &types::Connector, + connector: types::Connector, required_field_type: Vec, ) -> bool { required_fields @@ -170,7 +170,7 @@ fn is_dynamic_fields_required( .get(&payment_method) .and_then(|pm_type| pm_type.0.get(&payment_method_type)) .and_then(|required_fields_for_connector| { - required_fields_for_connector.fields.get(connector) + required_fields_for_connector.fields.get(&connector) }) .map(|required_fields_final| { required_fields_final @@ -371,7 +371,7 @@ async fn create_applepay_session_token( &state.conf.required_fields, enums::PaymentMethod::Wallet, enums::PaymentMethodType::ApplePay, - &connector.connector_name, + connector.connector_name, billing_variants, ) .then_some(payment_types::ApplePayBillingContactFields(vec![ @@ -399,7 +399,7 @@ async fn create_applepay_session_token( &state.conf.required_fields, enums::PaymentMethod::Wallet, enums::PaymentMethodType::ApplePay, - &connector.connector_name, + connector.connector_name, shipping_variants, ) .then_some(payment_types::ApplePayShippingContactFields(vec![ @@ -839,7 +839,7 @@ fn create_gpay_session_token( &state.conf.required_fields, enums::PaymentMethod::Wallet, enums::PaymentMethodType::GooglePay, - &connector.connector_name, + connector.connector_name, billing_variants, ) } else { @@ -901,7 +901,7 @@ fn create_gpay_session_token( &state.conf.required_fields, enums::PaymentMethod::Wallet, enums::PaymentMethodType::GooglePay, - &connector.connector_name, + connector.connector_name, shipping_variants, ) } else { diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index e7de03804d12..d3d9d51a2871 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1049,7 +1049,7 @@ pub fn validate_card_expiry( } pub fn infer_payment_type( - amount: &api::Amount, + amount: api::Amount, mandate_type: Option<&api::MandateTransactionType>, ) -> api_enums::PaymentType { match mandate_type { @@ -2830,7 +2830,7 @@ pub fn validate_payment_method_type_against_payment_method( } } -pub fn check_force_psync_precondition(status: &storage_enums::AttemptStatus) -> bool { +pub fn check_force_psync_precondition(status: storage_enums::AttemptStatus) -> bool { !matches!( status, storage_enums::AttemptStatus::Charged @@ -3254,11 +3254,11 @@ pub fn authenticate_client_secret( } pub(crate) fn validate_payment_status_against_allowed_statuses( - intent_status: &storage_enums::IntentStatus, + intent_status: storage_enums::IntentStatus, allowed_statuses: &[storage_enums::IntentStatus], action: &'static str, ) -> Result<(), errors::ApiErrorResponse> { - fp_utils::when(!allowed_statuses.contains(intent_status), || { + fp_utils::when(!allowed_statuses.contains(&intent_status), || { Err(errors::ApiErrorResponse::PreconditionFailed { message: format!( "You cannot {action} this payment because it has status {intent_status}", @@ -3268,11 +3268,11 @@ pub(crate) fn validate_payment_status_against_allowed_statuses( } pub(crate) fn validate_payment_status_against_not_allowed_statuses( - intent_status: &storage_enums::IntentStatus, + intent_status: storage_enums::IntentStatus, not_allowed_statuses: &[storage_enums::IntentStatus], action: &'static str, ) -> Result<(), errors::ApiErrorResponse> { - fp_utils::when(not_allowed_statuses.contains(intent_status), || { + fp_utils::when(not_allowed_statuses.contains(&intent_status), || { Err(errors::ApiErrorResponse::PreconditionFailed { message: format!( "You cannot {action} this payment because it has status {intent_status}", diff --git a/crates/router/src/core/payments/operations/payment_approve.rs b/crates/router/src/core/payments/operations/payment_approve.rs index 2bc18122b227..97832a081846 100644 --- a/crates/router/src/core/payments/operations/payment_approve.rs +++ b/crates/router/src/core/payments/operations/payment_approve.rs @@ -70,7 +70,7 @@ impl GetTracker, api::PaymentsCaptureRequest> .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[IntentStatus::Failed, IntentStatus::Succeeded], "approve", )?; diff --git a/crates/router/src/core/payments/operations/payment_cancel.rs b/crates/router/src/core/payments/operations/payment_cancel.rs index 8d7361cd257e..ef6570abf8c1 100644 --- a/crates/router/src/core/payments/operations/payment_cancel.rs +++ b/crates/router/src/core/payments/operations/payment_cancel.rs @@ -68,7 +68,7 @@ impl GetTracker, api::PaymentsCancelRequest> .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ enums::IntentStatus::Failed, enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs index 850fa738cd84..17e8801873dd 100644 --- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs +++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs @@ -75,7 +75,7 @@ impl GetTracker, api::PaymentsRequest> for Co helpers::authenticate_client_secret(request.client_secret.as_ref(), &payment_intent)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Failed, storage_enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index b56260b407eb..0cc2e38768be 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -115,7 +115,7 @@ impl GetTracker, api::PaymentsRequest> for Pa .contains(&header_payload.payment_confirm_source) { helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Cancelled, storage_enums::IntentStatus::Succeeded, @@ -127,7 +127,7 @@ impl GetTracker, api::PaymentsRequest> for Pa )?; } else { helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Cancelled, storage_enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/operations/payment_reject.rs b/crates/router/src/core/payments/operations/payment_reject.rs index 23531d2342dc..c747c7d984a8 100644 --- a/crates/router/src/core/payments/operations/payment_reject.rs +++ b/crates/router/src/core/payments/operations/payment_reject.rs @@ -64,7 +64,7 @@ impl GetTracker, PaymentsCancelRequest> for P .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ enums::IntentStatus::Cancelled, enums::IntentStatus::Failed, diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs index 1bc11854ad03..ebc663aaf395 100644 --- a/crates/router/src/core/payments/operations/payment_session.rs +++ b/crates/router/src/core/payments/operations/payment_session.rs @@ -68,7 +68,7 @@ impl GetTracker, api::PaymentsSessionRequest> .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Failed, storage_enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/operations/payment_start.rs b/crates/router/src/core/payments/operations/payment_start.rs index cad5dcfbd676..edcb0282bdd3 100644 --- a/crates/router/src/core/payments/operations/payment_start.rs +++ b/crates/router/src/core/payments/operations/payment_start.rs @@ -66,7 +66,7 @@ impl GetTracker, api::PaymentsStartRequest> f .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Failed, storage_enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/operations/payment_status.rs b/crates/router/src/core/payments/operations/payment_status.rs index a3a826ccd0e9..ab3a70aa1bb4 100644 --- a/crates/router/src/core/payments/operations/payment_status.rs +++ b/crates/router/src/core/payments/operations/payment_status.rs @@ -480,7 +480,7 @@ async fn get_tracker_for_sync< payment_method_info, force_sync: Some( request.force_sync - && (helpers::check_force_psync_precondition(&payment_attempt.status) + && (helpers::check_force_psync_precondition(payment_attempt.status) || contains_encoded_data), ), payment_attempt, diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 98491cab1db8..61a52e7dfb58 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -102,7 +102,7 @@ impl GetTracker, api::PaymentsRequest> for Pa )?; helpers::validate_payment_status_against_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::RequiresPaymentMethod, storage_enums::IntentStatus::RequiresConfirmation, diff --git a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs index 1ddaf0b6abf9..1b7acc796ec5 100644 --- a/crates/router/src/core/payments/operations/payments_incremental_authorization.rs +++ b/crates/router/src/core/payments/operations/payments_incremental_authorization.rs @@ -77,7 +77,7 @@ impl .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[enums::IntentStatus::RequiresCapture], "increment authorization", )?; diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs index 2d4054a60bed..537fcfc83f36 100644 --- a/crates/router/src/core/payments/operations/tax_calculation.rs +++ b/crates/router/src/core/payments/operations/tax_calculation.rs @@ -78,7 +78,7 @@ impl GetTracker, api::PaymentsDynamicTaxCalcu .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?; helpers::validate_payment_status_against_not_allowed_statuses( - &payment_intent.status, + payment_intent.status, &[ storage_enums::IntentStatus::Failed, storage_enums::IntentStatus::Succeeded, diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 9e0557d5b3eb..1b92950d0b55 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -775,7 +775,7 @@ where let apple_pay_flow = payments::decide_apple_pay_flow( state, - &payment_data.payment_attempt.payment_method_type, + payment_data.payment_attempt.payment_method_type, Some(merchant_connector_account), ); diff --git a/crates/router/src/core/payout_link.rs b/crates/router/src/core/payout_link.rs index 31e65e8e0a79..6ad2ed3a1c03 100644 --- a/crates/router/src/core/payout_link.rs +++ b/crates/router/src/core/payout_link.rs @@ -385,7 +385,7 @@ pub async fn filter_payout_methods( let currency_country_filter = check_currency_country_filters( payout_filter, request_payout_method_type, - &payout.destination_currency, + payout.destination_currency, address .as_ref() .and_then(|address| address.country) @@ -444,7 +444,7 @@ pub async fn filter_payout_methods( pub fn check_currency_country_filters( payout_method_filter: Option<&PaymentMethodFilters>, request_payout_method_type: &api_models::payment_methods::RequestPaymentMethodTypes, - currency: &common_enums::Currency, + currency: common_enums::Currency, country: Option<&common_enums::CountryAlpha2>, ) -> errors::RouterResult> { if matches!( @@ -473,7 +473,7 @@ pub fn check_currency_country_filters( currency_country_filter .currency .as_ref() - .map(|currency_hash_set| currency_hash_set.contains(currency)) + .map(|currency_hash_set| currency_hash_set.contains(¤cy)) }); Ok(currency_filter.or(country_filter)) } diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs index adf3c51fd80b..5104137fcd95 100644 --- a/crates/router/src/core/payouts.rs +++ b/crates/router/src/core/payouts.rs @@ -383,7 +383,7 @@ pub async fn payouts_confirm_core( let status = payout_attempt.status; helpers::validate_payout_status_against_not_allowed_statuses( - &status, + status, &[ storage_enums::PayoutStatus::Cancelled, storage_enums::PayoutStatus::Success, diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs index 49b18e53a0c7..5becf01597cb 100644 --- a/crates/router/src/core/payouts/helpers.rs +++ b/crates/router/src/core/payouts/helpers.rs @@ -1010,11 +1010,11 @@ pub fn is_payout_initiated(status: api_enums::PayoutStatus) -> bool { } pub(crate) fn validate_payout_status_against_not_allowed_statuses( - payout_status: &api_enums::PayoutStatus, + payout_status: api_enums::PayoutStatus, not_allowed_statuses: &[api_enums::PayoutStatus], action: &'static str, ) -> Result<(), errors::ApiErrorResponse> { - fp_utils::when(not_allowed_statuses.contains(payout_status), || { + fp_utils::when(not_allowed_statuses.contains(&payout_status), || { Err(errors::ApiErrorResponse::PreconditionFailed { message: format!( "You cannot {action} this payout because it has status {payout_status}", diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs index 9318e0c5b9fa..21227e06d94b 100644 --- a/crates/router/src/core/routing.rs +++ b/crates/router/src/core/routing.rs @@ -97,7 +97,7 @@ impl RoutingAlgorithmUpdate { request: &routing_types::RoutingConfigRequest, merchant_id: &common_utils::id_type::MerchantId, profile_id: common_utils::id_type::ProfileId, - transaction_type: &enums::TransactionType, + transaction_type: enums::TransactionType, ) -> Self { let algorithm_id = common_utils::generate_routing_id_of_default_length(); let timestamp = common_utils::date_time::now(); @@ -111,7 +111,7 @@ impl RoutingAlgorithmUpdate { algorithm_data: serde_json::json!(request.algorithm), created_at: timestamp, modified_at: timestamp, - algorithm_for: transaction_type.to_owned(), + algorithm_for: transaction_type, }; Self(algo) } @@ -168,7 +168,7 @@ pub async fn create_routing_algorithm_under_profile( key_store: domain::MerchantKeyStore, authentication_profile_id: Option, request: routing_types::RoutingConfigRequest, - transaction_type: &enums::TransactionType, + transaction_type: enums::TransactionType, ) -> RouterResponse { metrics::ROUTING_CREATE_REQUEST_RECEIVED.add(&metrics::CONTEXT, 1, &[]); let db = &*state.store; @@ -238,7 +238,7 @@ pub async fn create_routing_algorithm_under_profile( key_store: domain::MerchantKeyStore, authentication_profile_id: Option, request: routing_types::RoutingConfigRequest, - transaction_type: &enums::TransactionType, + transaction_type: enums::TransactionType, ) -> RouterResponse { metrics::ROUTING_CREATE_REQUEST_RECEIVED.add(&metrics::CONTEXT, 1, &[]); let db = state.store.as_ref(); diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rs index 9dc56b8bd0a7..2f5fed7aa84f 100644 --- a/crates/router/src/core/routing/helpers.rs +++ b/crates/router/src/core/routing/helpers.rs @@ -725,7 +725,7 @@ pub async fn push_metrics_with_update_window_for_success_based_routing( )?; let payment_status_attribute = - get_desired_payment_status_for_success_routing_metrics(&payment_attempt.status); + get_desired_payment_status_for_success_routing_metrics(payment_attempt.status); let first_success_based_connector_label = &success_based_connectors .labels_with_score @@ -746,7 +746,7 @@ pub async fn push_metrics_with_update_window_for_success_based_routing( ))?; let outcome = get_success_based_metrics_outcome_for_payment( - &payment_status_attribute, + payment_status_attribute, payment_connector.to_string(), first_success_based_connector.to_string(), ); @@ -843,7 +843,7 @@ pub async fn push_metrics_with_update_window_for_success_based_routing( #[cfg(all(feature = "v1", feature = "dynamic_routing"))] fn get_desired_payment_status_for_success_routing_metrics( - attempt_status: &common_enums::AttemptStatus, + attempt_status: common_enums::AttemptStatus, ) -> common_enums::AttemptStatus { match attempt_status { common_enums::AttemptStatus::Charged @@ -879,7 +879,7 @@ fn get_desired_payment_status_for_success_routing_metrics( #[cfg(all(feature = "v1", feature = "dynamic_routing"))] fn get_success_based_metrics_outcome_for_payment( - payment_status_attribute: &common_enums::AttemptStatus, + payment_status_attribute: common_enums::AttemptStatus, payment_connector: String, first_success_based_connector: String, ) -> common_enums::SuccessBasedRoutingConclusiveState { diff --git a/crates/router/src/core/user.rs b/crates/router/src/core/user.rs index 039e891e4225..abb1fd5bd3cb 100644 --- a/crates/router/src/core/user.rs +++ b/crates/router/src/core/user.rs @@ -2423,7 +2423,7 @@ pub async fn terminate_auth_select( // Skip SSO if continue with password(TOTP) if next_flow.get_flow() == domain::UserFlow::SPTFlow(domain::SPTFlow::SSO) - && !utils::user::is_sso_auth_type(&user_authentication_method.auth_type) + && !utils::user::is_sso_auth_type(user_authentication_method.auth_type) { next_flow = next_flow.skip(user_from_db, &state).await?; } diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rs index 32ad135a7d61..a64b0f39dc03 100644 --- a/crates/router/src/core/user/dashboard_metadata.rs +++ b/crates/router/src/core/user/dashboard_metadata.rs @@ -46,11 +46,11 @@ pub async fn get_multiple_metadata( for key in metadata_keys { let data = metadata.iter().find(|ele| ele.data_key == key); let resp; - if data.is_none() && utils::is_backfill_required(&key) { + if data.is_none() && utils::is_backfill_required(key) { let backfill_data = backfill_metadata(&state, &user, &key).await?; - resp = into_response(backfill_data.as_ref(), &key)?; + resp = into_response(backfill_data.as_ref(), key)?; } else { - resp = into_response(data, &key)?; + resp = into_response(data, key)?; } response.push(resp); } @@ -148,7 +148,7 @@ fn parse_get_request(data_enum: api::GetMetaDataRequest) -> DBEnum { fn into_response( data: Option<&DashboardMetadata>, - data_type: &DBEnum, + data_type: DBEnum, ) -> UserResult { match data_type { DBEnum::ProductionAgreement => Ok(api::GetMetaDataResponse::ProductionAgreement( diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rs index 776692d6bec1..084b59a31846 100644 --- a/crates/router/src/core/utils.rs +++ b/crates/router/src/core/utils.rs @@ -553,8 +553,8 @@ mod tests { // Dispute Stage can move linearly from PreDispute -> Dispute -> PreArbitration pub fn validate_dispute_stage( - prev_dispute_stage: &DisputeStage, - dispute_stage: &DisputeStage, + prev_dispute_stage: DisputeStage, + dispute_stage: DisputeStage, ) -> bool { match prev_dispute_stage { DisputeStage::PreDispute => true, @@ -596,7 +596,7 @@ pub fn validate_dispute_stage_and_dispute_status( dispute_stage: DisputeStage, dispute_status: DisputeStatus, ) -> CustomResult<(), errors::WebhooksFlowError> { - let dispute_stage_validation = validate_dispute_stage(&prev_dispute_stage, &dispute_stage); + let dispute_stage_validation = validate_dispute_stage(prev_dispute_stage, dispute_stage); let dispute_status_validation = if dispute_stage == prev_dispute_stage { validate_dispute_status(prev_dispute_status, dispute_status) } else { diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index bb8d0d4f2bd6..9bd85d0ca8d4 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -723,7 +723,7 @@ impl Routing { .app_data(web::Data::new(state.clone())) .service( web::resource("").route(web::post().to(|state, req, payload| { - routing::routing_create_config(state, req, payload, &TransactionType::Payment) + routing::routing_create_config(state, req, payload, TransactionType::Payment) })), ) .service( @@ -765,7 +765,7 @@ impl Routing { state, req, payload, - &TransactionType::Payment, + TransactionType::Payment, ) })), ) @@ -845,7 +845,7 @@ impl Routing { state, req, payload, - &TransactionType::Payout, + TransactionType::Payout, ) })), ) diff --git a/crates/router/src/routes/metrics/bg_metrics_collector.rs b/crates/router/src/routes/metrics/bg_metrics_collector.rs index 52d7777f5aa8..f3ba7076e536 100644 --- a/crates/router/src/routes/metrics/bg_metrics_collector.rs +++ b/crates/router/src/routes/metrics/bg_metrics_collector.rs @@ -2,7 +2,7 @@ use storage_impl::redis::cache; const DEFAULT_BG_METRICS_COLLECTION_INTERVAL_IN_SECS: u16 = 15; -pub fn spawn_metrics_collector(metrics_collection_interval_in_secs: &Option) { +pub fn spawn_metrics_collector(metrics_collection_interval_in_secs: Option) { let metrics_collection_interval = metrics_collection_interval_in_secs .unwrap_or(DEFAULT_BG_METRICS_COLLECTION_INTERVAL_IN_SECS); diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs index d22c5e974906..d7f46cd40bb0 100644 --- a/crates/router/src/routes/routing.rs +++ b/crates/router/src/routes/routing.rs @@ -21,7 +21,7 @@ pub async fn routing_create_config( state: web::Data, req: HttpRequest, json_payload: web::Json, - transaction_type: &enums::TransactionType, + transaction_type: enums::TransactionType, ) -> impl Responder { let flow = Flow::RoutingCreateConfig; Box::pin(oss_api::server_wrap( @@ -62,7 +62,7 @@ pub async fn routing_create_config( state: web::Data, req: HttpRequest, json_payload: web::Json, - transaction_type: &enums::TransactionType, + transaction_type: enums::TransactionType, ) -> impl Responder { let flow = Flow::RoutingCreateConfig; Box::pin(oss_api::server_wrap( diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index 1967eafd180c..041c53368446 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -1674,7 +1674,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; Ok(( (), @@ -1707,7 +1707,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; Ok(( UserFromToken { @@ -1747,7 +1747,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -1810,7 +1810,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; // Check if token has access to Organization that has been requested in the route if payload.org_id != self.organization_id { @@ -1855,7 +1855,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -1894,7 +1894,7 @@ where &state.session_state().tenant.tenant_id, )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -1964,7 +1964,7 @@ where .get_required_value(headers::X_PROFILE_ID)?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -2041,7 +2041,7 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let merchant_id_from_header = HeaderMapStruct::new(request_headers) .get_id_type_from_header::(headers::X_MERCHANT_ID)?; @@ -2110,7 +2110,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; // Check if token has access to MerchantId that has been requested through query param if payload.merchant_id != self.merchant_id { @@ -2151,7 +2151,7 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2215,7 +2215,7 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2286,7 +2286,7 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2360,7 +2360,7 @@ where } let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2427,7 +2427,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2492,7 +2492,7 @@ where .get_required_value(headers::X_PROFILE_ID)?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.required_permission, &role_info)?; + authorization::check_permission(self.required_permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2592,7 +2592,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2656,7 +2656,7 @@ where .get_id_type_from_header::(headers::X_PROFILE_ID)?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -2729,7 +2729,7 @@ where )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state @@ -3178,7 +3178,7 @@ where &state.session_state().tenant.tenant_id, )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let key_manager_state = &(&state.session_state()).into(); let key_store = state diff --git a/crates/router/src/services/authorization.rs b/crates/router/src/services/authorization.rs index 8f48ef068ce9..e0feaa5e817a 100644 --- a/crates/router/src/services/authorization.rs +++ b/crates/router/src/services/authorization.rs @@ -100,7 +100,7 @@ where } pub fn check_permission( - required_permission: &permissions::Permission, + required_permission: permissions::Permission, role_info: &roles::RoleInfo, ) -> RouterResult<()> { role_info diff --git a/crates/router/src/services/authorization/permission_groups.rs b/crates/router/src/services/authorization/permission_groups.rs index 57c385565a86..e7380753c991 100644 --- a/crates/router/src/services/authorization/permission_groups.rs +++ b/crates/router/src/services/authorization/permission_groups.rs @@ -128,13 +128,13 @@ impl ParentGroupExt for ParentGroup { .resources() .iter() .filter(|res| res.entities().iter().any(|entity| entity <= &entity_type)) - .map(|res| permissions::get_resource_name(res, &entity_type)) + .map(|res| permissions::get_resource_name(*res, entity_type)) .collect::>() .join(", "); Some(( parent, - format!("{} {}", permissions::get_scope_name(&scopes), resources), + format!("{} {}", permissions::get_scope_name(scopes), resources), )) }) .collect() diff --git a/crates/router/src/services/authorization/permissions.rs b/crates/router/src/services/authorization/permissions.rs index 6e472d55623b..8f4293450dfb 100644 --- a/crates/router/src/services/authorization/permissions.rs +++ b/crates/router/src/services/authorization/permissions.rs @@ -74,7 +74,7 @@ generate_permissions! { ] } -pub fn get_resource_name(resource: &Resource, entity_type: &EntityType) -> &'static str { +pub fn get_resource_name(resource: Resource, entity_type: EntityType) -> &'static str { match (resource, entity_type) { (Resource::Payment, _) => "Payments", (Resource::Refund, _) => "Refunds", @@ -98,7 +98,7 @@ pub fn get_resource_name(resource: &Resource, entity_type: &EntityType) -> &'sta } } -pub fn get_scope_name(scope: &PermissionScope) -> &'static str { +pub fn get_scope_name(scope: PermissionScope) -> &'static str { match scope { PermissionScope::Read => "View", PermissionScope::Write => "View and Manage", diff --git a/crates/router/src/services/authorization/roles.rs b/crates/router/src/services/authorization/roles.rs index bf66eb924669..ea05566c625d 100644 --- a/crates/router/src/services/authorization/roles.rs +++ b/crates/router/src/services/authorization/roles.rs @@ -70,7 +70,7 @@ impl RoleInfo { .collect() } - pub fn check_permission_exists(&self, required_permission: &Permission) -> bool { + pub fn check_permission_exists(&self, required_permission: Permission) -> bool { required_permission.entity_type() <= self.entity_type && self.get_permission_groups().iter().any(|group| { required_permission.scope() <= group.scope() diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index f5fa2d9a37eb..5b84de4d7650 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -248,15 +248,15 @@ pub enum SessionSurchargeDetails { impl SessionSurchargeDetails { pub fn fetch_surcharge_details( &self, - payment_method: &enums::PaymentMethod, - payment_method_type: &enums::PaymentMethodType, + payment_method: enums::PaymentMethod, + payment_method_type: enums::PaymentMethodType, card_network: Option<&enums::CardNetwork>, ) -> Option { match self { Self::Calculated(surcharge_metadata) => surcharge_metadata .get_surcharge_details(payments_types::SurchargeKey::PaymentMethodData( - *payment_method, - *payment_method_type, + payment_method, + payment_method_type, card_network.cloned(), )) .cloned(), diff --git a/crates/router/src/utils/user.rs b/crates/router/src/utils/user.rs index 443db741ae34..db8eeb70e6c1 100644 --- a/crates/router/src/utils/user.rs +++ b/crates/router/src/utils/user.rs @@ -272,7 +272,7 @@ pub fn get_oidc_sso_redirect_url(state: &SessionState, provider: &str) -> String format!("{}/redirect/oidc/{}", state.conf.user.base_url, provider) } -pub fn is_sso_auth_type(auth_type: &UserAuthType) -> bool { +pub fn is_sso_auth_type(auth_type: UserAuthType) -> bool { match auth_type { UserAuthType::OpenIdConnect => true, UserAuthType::Password | UserAuthType::MagicLink => false, diff --git a/crates/router/src/utils/user/dashboard_metadata.rs b/crates/router/src/utils/user/dashboard_metadata.rs index 3abdfdd3abe9..39a76844be1e 100644 --- a/crates/router/src/utils/user/dashboard_metadata.rs +++ b/crates/router/src/utils/user/dashboard_metadata.rs @@ -233,7 +233,7 @@ pub fn is_update_required(metadata: &UserResult) -> bool { } } -pub fn is_backfill_required(metadata_key: &DBEnum) -> bool { +pub fn is_backfill_required(metadata_key: DBEnum) -> bool { matches!( metadata_key, DBEnum::StripeConnected | DBEnum::PaypalConnected diff --git a/crates/router/tests/connectors/payeezy.rs b/crates/router/tests/connectors/payeezy.rs index 1bc81ebfe257..334910be9ef0 100644 --- a/crates/router/tests/connectors/payeezy.rs +++ b/crates/router/tests/connectors/payeezy.rs @@ -71,7 +71,7 @@ impl PayeezyTest { ..Default::default() }) } - fn get_request_interval(&self) -> u64 { + fn get_request_interval(self) -> u64 { 20 } } diff --git a/crates/router_derive/src/macros/to_encryptable.rs b/crates/router_derive/src/macros/to_encryptable.rs index 561c3a723719..60895c50a8f9 100644 --- a/crates/router_derive/src/macros/to_encryptable.rs +++ b/crates/router_derive/src/macros/to_encryptable.rs @@ -124,7 +124,7 @@ enum StructType { impl StructType { /// Generates the fields for temporary structs which consists of the fields that should be /// encrypted/decrypted - fn generate_struct_fields(&self, fields: &[(Field, Ident)]) -> Vec { + fn generate_struct_fields(self, fields: &[(Field, Ident)]) -> Vec { fields .iter() .map(|(field, inner_ty)| { @@ -162,7 +162,7 @@ impl StructType { /// Generates the ToEncryptable trait implementation fn generate_impls( - &self, + self, gen1: proc_macro2::TokenStream, gen2: proc_macro2::TokenStream, gen3: proc_macro2::TokenStream, @@ -177,7 +177,7 @@ impl StructType { let field_ident = &field.ident; let field_ident_string = field_ident.as_ref().map(|s| s.to_string()); - if is_option || *self == Self::Updated { + if is_option || self == Self::Updated { quote! { self.#field_ident.map(|s| map.insert(#field_ident_string.to_string(), s)) } } else { quote! { map.insert(#field_ident_string.to_string(), self.#field_ident) } @@ -191,7 +191,7 @@ impl StructType { let field_ident = &field.ident; let field_ident_string = field_ident.as_ref().map(|s| s.to_string()); - if is_option || *self == Self::Updated { + if is_option || self == Self::Updated { quote! { #field_ident: map.remove(#field_ident_string) } } else { quote! { diff --git a/crates/router_env/src/logger/config.rs b/crates/router_env/src/logger/config.rs index 746c8ee9580a..431fb5a6368e 100644 --- a/crates/router_env/src/logger/config.rs +++ b/crates/router_env/src/logger/config.rs @@ -47,7 +47,7 @@ pub struct Level(pub(super) tracing::Level); impl Level { /// Returns the most verbose [`tracing::Level`] - pub fn into_level(&self) -> tracing::Level { + pub fn into_level(self) -> tracing::Level { self.0 } } diff --git a/crates/router_env/src/logger/formatter.rs b/crates/router_env/src/logger/formatter.rs index 5c3341026c20..bbcf1e230616 100644 --- a/crates/router_env/src/logger/formatter.rs +++ b/crates/router_env/src/logger/formatter.rs @@ -330,7 +330,7 @@ where /// Serialize event into a buffer of bytes using parent span. pub fn event_serialize( &self, - span: &Option<&SpanRef<'_, S>>, + span: Option<&SpanRef<'_, S>>, event: &Event<'_>, ) -> std::io::Result> where @@ -347,7 +347,7 @@ where let name = span.map_or("?", SpanRef::name); Self::event_message(span, event, &mut storage); - self.common_serialize(&mut map_serializer, event.metadata(), *span, &storage, name)?; + self.common_serialize(&mut map_serializer, event.metadata(), span, &storage, name)?; map_serializer.end()?; Ok(buffer) @@ -366,11 +366,8 @@ where /// Format message of an event. /// /// Examples: "[FN_WITHOUT_COLON - EVENT] Message" - fn event_message( - span: &Option<&SpanRef<'_, S>>, - event: &Event<'_>, - storage: &mut Storage<'_>, - ) where + fn event_message(span: Option<&SpanRef<'_, S>>, event: &Event<'_>, storage: &mut Storage<'_>) + where S: Subscriber + for<'a> LookupSpan<'a>, { // Get value of kept "message" or "target" if does not exist. @@ -397,7 +394,7 @@ where // Event could have no span. let span = ctx.lookup_current(); - let result: std::io::Result> = self.event_serialize(&span.as_ref(), event); + let result: std::io::Result> = self.event_serialize(span.as_ref(), event); if let Ok(formatted) = result { let _ = self.flush(formatted); } diff --git a/crates/scheduler/src/utils.rs b/crates/scheduler/src/utils.rs index 8c2424d5017e..e4b636ac5f11 100644 --- a/crates/scheduler/src/utils.rs +++ b/crates/scheduler/src/utils.rs @@ -321,10 +321,10 @@ pub fn get_schedule_time( pub fn get_pm_schedule_time( mapping: process_data::PaymentMethodsPTMapping, - pm: &enums::PaymentMethod, + pm: enums::PaymentMethod, retry_count: i32, ) -> Option { - let mapping = match mapping.custom_pm_mapping.get(pm) { + let mapping = match mapping.custom_pm_mapping.get(&pm) { Some(map) => map.clone(), None => mapping.default_mapping, }; diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs index 5954f4791a57..9b306ec8b077 100644 --- a/crates/storage_impl/src/lib.rs +++ b/crates/storage_impl/src/lib.rs @@ -280,7 +280,7 @@ pub trait DataModelExt { } pub(crate) fn diesel_error_to_data_error( - diesel_error: &diesel_models::errors::DatabaseError, + diesel_error: diesel_models::errors::DatabaseError, ) -> StorageError { match diesel_error { diesel_models::errors::DatabaseError::DatabaseConnectionError => { @@ -293,7 +293,7 @@ pub(crate) fn diesel_error_to_data_error( entity: "entity ", key: None, }, - _ => StorageError::DatabaseError(error_stack::report!(*diesel_error)), + _ => StorageError::DatabaseError(error_stack::report!(diesel_error)), } } diff --git a/crates/storage_impl/src/lookup.rs b/crates/storage_impl/src/lookup.rs index eec85e267b99..2f8a743a81a7 100644 --- a/crates/storage_impl/src/lookup.rs +++ b/crates/storage_impl/src/lookup.rs @@ -44,7 +44,7 @@ impl ReverseLookupInterface for RouterStore { .await .change_context(errors::StorageError::DatabaseConnectionError)?; new.insert(&conn).await.map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } @@ -58,7 +58,7 @@ impl ReverseLookupInterface for RouterStore { DieselReverseLookup::find_by_lookup_id(id, &conn) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 4eedfd5005e6..06c7fefe85fa 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -60,7 +60,7 @@ impl PaymentAttemptInterface for RouterStore { .insert(&conn) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -83,7 +83,7 @@ impl PaymentAttemptInterface for RouterStore { .insert(&conn) .await .map_err(|error| { - let new_error = diesel_error_to_data_error(error.current_context()); + let new_error = diesel_error_to_data_error(*error.current_context()); error.change_context(new_error) })? .convert( @@ -108,7 +108,7 @@ impl PaymentAttemptInterface for RouterStore { .update_with_attempt_id(&conn, payment_attempt.to_storage_model()) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -135,7 +135,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|error| { - let new_error = diesel_error_to_data_error(error.current_context()); + let new_error = diesel_error_to_data_error(*error.current_context()); error.change_context(new_error) })? .convert( @@ -165,7 +165,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -187,7 +187,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -209,7 +209,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -231,7 +231,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -255,7 +255,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })? .convert( @@ -286,7 +286,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -313,7 +313,7 @@ impl PaymentAttemptInterface for RouterStore { DieselPaymentAttempt::get_filters_for_payments(&conn, intents.as_slice(), merchant_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map( @@ -352,7 +352,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -370,7 +370,7 @@ impl PaymentAttemptInterface for RouterStore { DieselPaymentAttempt::find_by_merchant_id_payment_id(&conn, merchant_id, payment_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(|a| { @@ -393,7 +393,7 @@ impl PaymentAttemptInterface for RouterStore { DieselPaymentAttempt::find_by_merchant_id_attempt_id(&conn, merchant_id, attempt_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PaymentAttempt::from_storage_model) @@ -413,7 +413,7 @@ impl PaymentAttemptInterface for RouterStore { DieselPaymentAttempt::find_by_id(&conn, attempt_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })? .convert( @@ -464,7 +464,7 @@ impl PaymentAttemptInterface for RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs index 15f1aa243708..ebf75a58b2c6 100644 --- a/crates/storage_impl/src/payments/payment_intent.rs +++ b/crates/storage_impl/src/payments/payment_intent.rs @@ -297,7 +297,7 @@ impl PaymentIntentInterface for KVRouterStore { DieselPaymentIntent::find_by_payment_id_merchant_id(&conn, payment_id, merchant_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) }; @@ -358,7 +358,7 @@ impl PaymentIntentInterface for KVRouterStore { let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })?; @@ -481,7 +481,7 @@ impl PaymentIntentInterface for crate::RouterStore { .insert(&conn) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })?; @@ -515,7 +515,7 @@ impl PaymentIntentInterface for crate::RouterStore { .update(&conn, diesel_payment_intent_update) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })?; @@ -550,7 +550,7 @@ impl PaymentIntentInterface for crate::RouterStore { .update(&conn, diesel_payment_intent_update) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })?; @@ -579,7 +579,7 @@ impl PaymentIntentInterface for crate::RouterStore { DieselPaymentIntent::find_by_payment_id_merchant_id(&conn, payment_id, merchant_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .async_and_then(|diesel_payment_intent| async { @@ -608,7 +608,7 @@ impl PaymentIntentInterface for crate::RouterStore { let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) })?; diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rs index 3ac66a2c3012..caefa4eeda8c 100644 --- a/crates/storage_impl/src/payouts/payout_attempt.rs +++ b/crates/storage_impl/src/payouts/payout_attempt.rs @@ -395,7 +395,7 @@ impl PayoutAttemptInterface for crate::RouterStore { .insert(&conn) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PayoutAttempt::from_storage_model) @@ -415,7 +415,7 @@ impl PayoutAttemptInterface for crate::RouterStore { .update_with_attempt_id(&conn, payout.to_storage_model()) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(PayoutAttempt::from_storage_model) @@ -437,7 +437,7 @@ impl PayoutAttemptInterface for crate::RouterStore { .await .map(PayoutAttempt::from_storage_model) .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } @@ -458,7 +458,7 @@ impl PayoutAttemptInterface for crate::RouterStore { .await .map(PayoutAttempt::from_storage_model) .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } @@ -479,7 +479,7 @@ impl PayoutAttemptInterface for crate::RouterStore { DieselPayoutAttempt::get_filters_for_payouts(&conn, payouts.as_slice(), merchant_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map( diff --git a/crates/storage_impl/src/payouts/payouts.rs b/crates/storage_impl/src/payouts/payouts.rs index 2f6540732fd6..0c69b2f24120 100644 --- a/crates/storage_impl/src/payouts/payouts.rs +++ b/crates/storage_impl/src/payouts/payouts.rs @@ -235,7 +235,7 @@ impl PayoutsInterface for KVRouterStore { DieselPayouts::find_by_merchant_id_payout_id(&conn, merchant_id, payout_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) }; @@ -283,7 +283,7 @@ impl PayoutsInterface for KVRouterStore { DieselPayouts::find_optional_by_merchant_id_payout_id(&conn, merchant_id, payout_id) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) }; @@ -423,7 +423,7 @@ impl PayoutsInterface for crate::RouterStore { .insert(&conn) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(Payouts::from_storage_model) @@ -443,7 +443,7 @@ impl PayoutsInterface for crate::RouterStore { .update(&conn, payout.to_storage_model()) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) .map(Payouts::from_storage_model) @@ -461,7 +461,7 @@ impl PayoutsInterface for crate::RouterStore { .await .map(Payouts::from_storage_model) .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } @@ -478,7 +478,7 @@ impl PayoutsInterface for crate::RouterStore { .await .map(|x| x.map(Payouts::from_storage_model)) .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } @@ -814,7 +814,7 @@ impl PayoutsInterface for crate::RouterStore { ) .await .map_err(|er| { - let new_err = diesel_error_to_data_error(er.current_context()); + let new_err = diesel_error_to_data_error(*er.current_context()); er.change_context(new_err) }) } From f9818a9a2ae736e2a5c196564bfd89ca719b5b86 Mon Sep 17 00:00:00 2001 From: Sanchith Hegde Date: Tue, 3 Dec 2024 01:01:25 +0530 Subject: [PATCH 2/4] refactor(common_enums): specify reason to allow lint as comment instead of within attribute --- crates/common_enums/src/transformers.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs index ad0d4ecfe93c..7611ae127ee7 100644 --- a/crates/common_enums/src/transformers.rs +++ b/crates/common_enums/src/transformers.rs @@ -1905,10 +1905,8 @@ mod custom_serde { use super::*; - #[allow( - clippy::trivially_copy_pass_by_ref, - reason = "`serde::Serialize` needs it to accept `&Country`" - )] + // `serde::Serialize` implementation needs the function to accept `&Country` + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, @@ -1941,10 +1939,8 @@ mod custom_serde { use super::*; - #[allow( - clippy::trivially_copy_pass_by_ref, - reason = "`serde::Serialize` needs it to accept `&Country`" - )] + // `serde::Serialize` implementation needs the function to accept `&Country` + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, @@ -1977,10 +1973,8 @@ mod custom_serde { use super::*; - #[allow( - clippy::trivially_copy_pass_by_ref, - reason = "`serde::Serialize` needs it to accept `&Country`" - )] + // `serde::Serialize` implementation needs the function to accept `&Country` + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn serialize(code: &Country, serializer: S) -> Result where S: serde::Serializer, From 822e1bdd0f265fa35f392b1d1ba1cc40475a0a58 Mon Sep 17 00:00:00 2001 From: Sanchith Hegde Date: Wed, 4 Dec 2024 16:35:16 +0530 Subject: [PATCH 3/4] fix: fix failing builds --- crates/router/src/services/authentication.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/router/src/services/authentication.rs b/crates/router/src/services/authentication.rs index 575239203e3f..f465719949aa 100644 --- a/crates/router/src/services/authentication.rs +++ b/crates/router/src/services/authentication.rs @@ -3255,7 +3255,7 @@ where &state.session_state().tenant.tenant_id, )?; let role_info = authorization::get_role_info(state, &payload).await?; - authorization::check_permission(&self.permission, &role_info)?; + authorization::check_permission(self.permission, &role_info)?; let user = UserFromToken { user_id: payload.user_id.clone(), From df306cb0dfbb5e67f41d6b58ce55db34365e4a9f Mon Sep 17 00:00:00 2001 From: Sanchith Hegde Date: Thu, 5 Dec 2024 18:21:08 +0530 Subject: [PATCH 4/4] fix: fix failing build --- .../metrics/sessionized_metrics/refund_error_message.rs | 4 ++-- .../src/refunds/metrics/sessionized_metrics/refund_reason.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_error_message.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_error_message.rs index 72e32907efbd..c6579005fac4 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_error_message.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_error_message.rs @@ -37,7 +37,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -127,7 +127,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut outer_query_builder) .attach_printable("Error adding granularity") diff --git a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_reason.rs b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_reason.rs index 0df28901e8f6..f7a2e11676f4 100644 --- a/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_reason.rs +++ b/crates/analytics/src/refunds/metrics/sessionized_metrics/refund_reason.rs @@ -36,7 +36,7 @@ where dimensions: &[RefundDimensions], auth: &AuthInfo, filters: &RefundFilters, - granularity: &Option, + granularity: Option, time_range: &TimeRange, pool: &T, ) -> MetricsResult> { @@ -119,7 +119,7 @@ where .switch()?; } - if let Some(granularity) = granularity.as_ref() { + if let Some(granularity) = granularity { granularity .set_group_by_clause(&mut outer_query_builder) .attach_printable("Error adding granularity")