mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
refactor(merchant_id): create domain type for merchant_id (#5408)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
@ -31,17 +31,17 @@ use crate::{
|
||||
pub async fn api_events_core(
|
||||
pool: &AnalyticsProvider,
|
||||
req: ApiLogsRequest,
|
||||
merchant_id: String,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> AnalyticsResult<Vec<ApiLogsResult>> {
|
||||
let data = match pool {
|
||||
AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented(
|
||||
"API Events not implemented for SQLX",
|
||||
))
|
||||
.attach_printable("SQL Analytics is not implemented for API Events"),
|
||||
AnalyticsProvider::Clickhouse(pool) => get_api_event(&merchant_id, req, pool).await,
|
||||
AnalyticsProvider::Clickhouse(pool) => get_api_event(merchant_id, req, pool).await,
|
||||
AnalyticsProvider::CombinedSqlx(_sqlx_pool, ckh_pool)
|
||||
| AnalyticsProvider::CombinedCkh(_sqlx_pool, ckh_pool) => {
|
||||
get_api_event(&merchant_id, req, ckh_pool).await
|
||||
get_api_event(merchant_id, req, ckh_pool).await
|
||||
}
|
||||
}
|
||||
.switch()?;
|
||||
@ -51,7 +51,7 @@ pub async fn api_events_core(
|
||||
pub async fn get_filters(
|
||||
pool: &AnalyticsProvider,
|
||||
req: GetApiEventFiltersRequest,
|
||||
merchant_id: String,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
) -> AnalyticsResult<ApiEventFiltersResponse> {
|
||||
use api_models::analytics::{api_event::ApiEventDimensions, ApiEventFilterValue};
|
||||
|
||||
@ -68,7 +68,7 @@ pub async fn get_filters(
|
||||
AnalyticsProvider::Clickhouse(ckh_pool)
|
||||
| AnalyticsProvider::CombinedSqlx(_, ckh_pool)
|
||||
| AnalyticsProvider::CombinedCkh(_, ckh_pool) => {
|
||||
get_api_event_filter_for_dimension(dim, &merchant_id, &req.time_range, ckh_pool)
|
||||
get_api_event_filter_for_dimension(dim, merchant_id, &req.time_range, ckh_pool)
|
||||
.await
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ pub async fn get_filters(
|
||||
#[instrument(skip_all)]
|
||||
pub async fn get_api_event_metrics(
|
||||
pool: &AnalyticsProvider,
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
req: GetApiEventMetricRequest,
|
||||
) -> AnalyticsResult<MetricsResponse<ApiMetricsBucketResponse>> {
|
||||
let mut metrics_accumulator: HashMap<ApiEventMetricsBucketIdentifier, ApiEventMetricRow> =
|
||||
|
||||
@ -14,7 +14,7 @@ use crate::{
|
||||
pub trait ApiLogsFilterAnalytics: LoadRow<ApiLogsResult> {}
|
||||
|
||||
pub async fn get_api_event<T>(
|
||||
merchant_id: &String,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
query_param: ApiLogsRequest,
|
||||
pool: &T,
|
||||
) -> FiltersResult<Vec<ApiLogsResult>>
|
||||
@ -102,7 +102,7 @@ where
|
||||
}
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ApiLogsResult {
|
||||
pub merchant_id: String,
|
||||
pub merchant_id: common_utils::id_type::MerchantId,
|
||||
pub payment_id: Option<String>,
|
||||
pub refund_id: Option<String>,
|
||||
pub payment_method_id: Option<String>,
|
||||
|
||||
@ -12,7 +12,7 @@ pub trait ApiEventFilterAnalytics: LoadRow<ApiEventFilter> {}
|
||||
|
||||
pub async fn get_api_event_filter_for_dimension<T>(
|
||||
dimension: ApiEventDimensions,
|
||||
merchant_id: &String,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
time_range: &TimeRange,
|
||||
pool: &T,
|
||||
) -> FiltersResult<Vec<ApiEventFilter>>
|
||||
|
||||
@ -43,7 +43,7 @@ where
|
||||
async fn load_metrics(
|
||||
&self,
|
||||
dimensions: &[ApiEventDimensions],
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
filters: &ApiEventFilters,
|
||||
granularity: &Option<Granularity>,
|
||||
time_range: &TimeRange,
|
||||
@ -64,7 +64,7 @@ where
|
||||
async fn load_metrics(
|
||||
&self,
|
||||
dimensions: &[ApiEventDimensions],
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
filters: &ApiEventFilters,
|
||||
granularity: &Option<Granularity>,
|
||||
time_range: &TimeRange,
|
||||
|
||||
@ -30,7 +30,7 @@ where
|
||||
async fn load_metrics(
|
||||
&self,
|
||||
_dimensions: &[ApiEventDimensions],
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
filters: &ApiEventFilters,
|
||||
granularity: &Option<Granularity>,
|
||||
time_range: &TimeRange,
|
||||
|
||||
@ -33,7 +33,7 @@ where
|
||||
async fn load_metrics(
|
||||
&self,
|
||||
_dimensions: &[ApiEventDimensions],
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
filters: &ApiEventFilters,
|
||||
granularity: &Option<Granularity>,
|
||||
time_range: &TimeRange,
|
||||
|
||||
@ -30,7 +30,7 @@ where
|
||||
async fn load_metrics(
|
||||
&self,
|
||||
_dimensions: &[ApiEventDimensions],
|
||||
merchant_id: &str,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
filters: &ApiEventFilters,
|
||||
granularity: &Option<Granularity>,
|
||||
time_range: &TimeRange,
|
||||
|
||||
Reference in New Issue
Block a user