Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(globalsearch): Added search_tags based filter for global search in dashboard (#5341)

Sandeep Kumar35c9b8afe1a0
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 79605b77fa..12b3d2a05f 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -9515,11 +9515,11 @@
"nullable": true
},
"search_tags": {
- "allOf": [
- {
- "$ref": "#/components/schemas/RedirectResponse"
- }
- ],
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Additional tags to be used for global search",
"nullable": true
}
}
diff --git a/crates/analytics/src/search.rs b/crates/analytics/src/search.rs
index 269864bf44..a5bd117bd6 100644
--- a/crates/analytics/src/search.rs
+++ b/crates/analytics/src/search.rs
@@ -66,6 +66,24 @@ pub async fn msearch_results(
.switch()?;
}
};
+ if let Some(search_tags) = filters.search_tags {
+ if !search_tags.is_empty() {
+ query_builder
+ .add_filter_clause(
+ "feature_metadata.search_tags.keyword".to_string(),
+ search_tags
+ .iter()
+ .filter_map(|search_tag| {
+ // TODO: Add trait based inputs instead of converting this to strings
+ serde_json::to_value(search_tag)
+ .ok()
+ .and_then(|a| a.as_str().map(|a| a.to_string()))
+ })
+ .collect(),
+ )
+ .switch()?;
+ }
+ };
};
let response_text: OpenMsearchOutput = client
@@ -173,6 +191,24 @@ pub async fn search_results(
.switch()?;
}
};
+ if let Some(search_tags) = filters.search_tags {
+ if !search_tags.is_empty() {
+ query_builder
+ .add_filter_clause(
+ "feature_metadata.search_tags.keyword".to_string(),
+ search_tags
+ .iter()
+ .filter_map(|search_tag| {
+ // TODO: Add trait based inputs instead of converting this to strings
+ serde_json::to_value(search_tag)
+ .ok()
+ .and_then(|a| a.as_str().map(|a| a.to_string()))
+ })
+ .collect(),
+ )
+ .switch()?;
+ }
+ };
};
query_builder
.set_offset_n_count(search_req.offset, search_req.count)
diff --git a/crates/api_models/src/analytics/search.rs b/crates/api_models/src/analytics/search.rs
index 034a2a9435..d1af00de56 100644
--- a/crates/api_models/src/analytics/search.rs
+++ b/crates/api_models/src/analytics/search.rs
@@ -1,4 +1,5 @@
use common_utils::hashing::HashedString;
+use masking::WithType;
use serde_json::Value;
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
@@ -7,6 +8,7 @@ pub struct SearchFilters {
pub currency: Option<Vec<String>>,
pub status: Option<Vec<String>>,
pub customer_email: Option<Vec<HashedString<common_utils::pii::EmailStrategy>>>,
+ pub search_tags: Option<Vec<HashedString<WithType>>>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index f53507fc13..c04af20449 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -9,11 +9,12 @@ use common_utils::{
consts::default_payments_list_limit,
crypto,
ext_traits::{ConfigExt, Encode},
+ hashing::HashedString,
id_type,
pii::{self, Email},
types::{MinorUnit, StringMajorUnit},
};
-use masking::{PeekInterface, Secret};
+use masking::{PeekInterface, Secret, WithType};
use router_derive::Setter;
use serde::{
de::{self, Unexpected, Visitor},
@@ -4987,11 +4988,12 @@ pub struct PaymentsStartRequest {
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct FeatureMetadata {
/// Redirection response coming in request as metadata field only for redirection scenarios
+ #[schema(value_type = Option<RedirectResponse>)]
pub redirect_response: Option<RedirectResponse>,
// TODO: Convert this to hashedstrings to avoid PII sensitive data
/// Additional tags to be used for global search
- #[schema(value_type = Option<RedirectResponse>)]
- pub search_tags: Option<Vec<Secret<String>>>,
+ #[schema(value_type = Option<Vec<String>>)]
+ pub search_tags: Option<Vec<HashedString<WithType>>>,
}
///frm message is an object sent inside the payments response...when frm is invoked, its value is Some(...), else its None
diff --git a/crates/masking/src/strategy.rs b/crates/masking/src/strategy.rs
index 8b4d9b0ec3..eb705ca490 100644
--- a/crates/masking/src/strategy.rs
+++ b/crates/masking/src/strategy.rs
@@ -7,6 +7,8 @@ pub trait Strategy<T> {
}
/// Debug with type
+#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
+#[derive(Debug, Copy, Clone)]
pub enum WithType {}
impl<T> Strategy<T> for WithType {