mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(analytics): fixed response code to 501 (#3119)
Co-authored-by: Sampras Lopes <lsampras@pm.me>
This commit is contained in:
@ -8,6 +8,7 @@ use api_models::analytics::{
|
||||
AnalyticsMetadata, ApiEventFiltersResponse, GetApiEventFiltersRequest,
|
||||
GetApiEventMetricRequest, MetricsResponse,
|
||||
};
|
||||
use common_utils::errors::ReportSwitchExt;
|
||||
use error_stack::{IntoReport, ResultExt};
|
||||
use router_env::{
|
||||
instrument, logger,
|
||||
@ -32,16 +33,18 @@ pub async fn api_events_core(
|
||||
merchant_id: String,
|
||||
) -> AnalyticsResult<Vec<ApiLogsResult>> {
|
||||
let data = match pool {
|
||||
AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented)
|
||||
.into_report()
|
||||
.attach_printable("SQL Analytics is not implemented for API Events"),
|
||||
AnalyticsProvider::Sqlx(_) => Err(FiltersError::NotImplemented(
|
||||
"API Events not implemented for SQLX",
|
||||
))
|
||||
.into_report()
|
||||
.attach_printable("SQL Analytics is not implemented for API Events"),
|
||||
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
|
||||
}
|
||||
}
|
||||
.change_context(AnalyticsError::UnknownError)?;
|
||||
.switch()?;
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@ -58,9 +61,11 @@ pub async fn get_filters(
|
||||
let mut res = ApiEventFiltersResponse::default();
|
||||
for dim in req.group_by_names {
|
||||
let values = match pool {
|
||||
AnalyticsProvider::Sqlx(_pool) => Err(FiltersError::NotImplemented)
|
||||
.into_report()
|
||||
.attach_printable("SQL Analytics is not implemented for API Events"),
|
||||
AnalyticsProvider::Sqlx(_pool) => Err(FiltersError::NotImplemented(
|
||||
"API Events not implemented for SQLX",
|
||||
))
|
||||
.into_report()
|
||||
.attach_printable("SQL Analytics is not implemented for API Events"),
|
||||
AnalyticsProvider::Clickhouse(ckh_pool)
|
||||
| AnalyticsProvider::CombinedSqlx(_, ckh_pool)
|
||||
| AnalyticsProvider::CombinedCkh(_, ckh_pool) => {
|
||||
@ -68,7 +73,7 @@ pub async fn get_filters(
|
||||
.await
|
||||
}
|
||||
}
|
||||
.change_context(AnalyticsError::UnknownError)?
|
||||
.switch()?
|
||||
.into_iter()
|
||||
.filter_map(|fil: ApiEventFilter| match dim {
|
||||
ApiEventDimensions::StatusCode => fil.status_code.map(|i| i.to_string()),
|
||||
|
||||
Reference in New Issue
Block a user