mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(global-search): dashboard globalsearch apis (#3831)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -8,6 +8,9 @@ pub mod routes {
|
||||
outgoing_webhook_event::outgoing_webhook_events_core, sdk_events::sdk_events_core,
|
||||
};
|
||||
use api_models::analytics::{
|
||||
search::{
|
||||
GetGlobalSearchRequest, GetSearchRequest, GetSearchRequestWithIndex, SearchIndex,
|
||||
},
|
||||
GenerateReportRequest, GetApiEventFiltersRequest, GetApiEventMetricRequest,
|
||||
GetDisputeMetricRequest, GetPaymentFiltersRequest, GetPaymentMetricRequest,
|
||||
GetRefundFilterRequest, GetRefundMetricRequest, GetSdkEventFiltersRequest,
|
||||
@ -89,6 +92,12 @@ pub mod routes {
|
||||
web::resource("metrics/api_events")
|
||||
.route(web::post().to(get_api_events_metrics)),
|
||||
)
|
||||
.service(
|
||||
web::resource("search").route(web::post().to(get_global_search_results)),
|
||||
)
|
||||
.service(
|
||||
web::resource("search/{domain}").route(web::post().to(get_search_results)),
|
||||
)
|
||||
.service(
|
||||
web::resource("filters/disputes")
|
||||
.route(web::post().to(get_dispute_filters)),
|
||||
@ -113,7 +122,7 @@ pub mod routes {
|
||||
state,
|
||||
&req,
|
||||
domain.into_inner(),
|
||||
|_, _, domain| async {
|
||||
|_, _, domain: analytics::AnalyticsDomain| async {
|
||||
analytics::core::get_domain_info(domain)
|
||||
.await
|
||||
.map(ApplicationResponse::Json)
|
||||
@ -592,6 +601,63 @@ pub mod routes {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_global_search_results(
|
||||
state: web::Data<AppState>,
|
||||
req: actix_web::HttpRequest,
|
||||
json_payload: web::Json<GetGlobalSearchRequest>,
|
||||
) -> impl Responder {
|
||||
let flow = AnalyticsFlow::GetGlobalSearchResults;
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state.clone(),
|
||||
&req,
|
||||
json_payload.into_inner(),
|
||||
|state, auth: AuthenticationData, req| async move {
|
||||
analytics::search::msearch_results(
|
||||
req,
|
||||
&auth.merchant_account.merchant_id,
|
||||
state.conf.opensearch.clone(),
|
||||
)
|
||||
.await
|
||||
.map(ApplicationResponse::Json)
|
||||
},
|
||||
&auth::JWTAuth(Permission::Analytics),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_search_results(
|
||||
state: web::Data<AppState>,
|
||||
req: actix_web::HttpRequest,
|
||||
json_payload: web::Json<GetSearchRequest>,
|
||||
index: actix_web::web::Path<SearchIndex>,
|
||||
) -> impl Responder {
|
||||
let flow = AnalyticsFlow::GetSearchResults;
|
||||
let indexed_req = GetSearchRequestWithIndex {
|
||||
search_req: json_payload.into_inner(),
|
||||
index: index.into_inner(),
|
||||
};
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state.clone(),
|
||||
&req,
|
||||
indexed_req,
|
||||
|state, auth: AuthenticationData, req| async move {
|
||||
analytics::search::search_results(
|
||||
req,
|
||||
&auth.merchant_account.merchant_id,
|
||||
state.conf.opensearch.clone(),
|
||||
)
|
||||
.await
|
||||
.map(ApplicationResponse::Json)
|
||||
},
|
||||
&auth::JWTAuth(Permission::Analytics),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_dispute_filters(
|
||||
state: web::Data<AppState>,
|
||||
req: actix_web::HttpRequest,
|
||||
|
||||
@ -350,6 +350,8 @@ pub(crate) async fn fetch_raw_secrets(
|
||||
payment_link: conf.payment_link,
|
||||
#[cfg(feature = "olap")]
|
||||
analytics,
|
||||
#[cfg(feature = "olap")]
|
||||
opensearch: conf.opensearch,
|
||||
#[cfg(feature = "kv_store")]
|
||||
kv_config: conf.kv_config,
|
||||
#[cfg(feature = "frm")]
|
||||
|
||||
@ -4,7 +4,7 @@ use std::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
use analytics::ReportConfig;
|
||||
use analytics::{OpensearchConfig, ReportConfig};
|
||||
use api_models::{enums, payment_methods::RequiredFieldInfo};
|
||||
use common_utils::ext_traits::ConfigExt;
|
||||
use config::{Environment, File};
|
||||
@ -112,6 +112,8 @@ pub struct Settings<S: SecretState> {
|
||||
pub frm: Frm,
|
||||
#[cfg(feature = "olap")]
|
||||
pub report_download_config: ReportConfig,
|
||||
#[cfg(feature = "olap")]
|
||||
pub opensearch: OpensearchConfig,
|
||||
pub events: EventsConfig,
|
||||
#[cfg(feature = "olap")]
|
||||
pub connector_onboarding: SecretStateContainer<ConnectorOnboarding, S>,
|
||||
|
||||
Reference in New Issue
Block a user