fix all the single settings route and add the searchable attributes Updated event

This commit is contained in:
Tamo 2021-10-28 13:02:48 +02:00 committed by marin postma
parent fc2f23d36c
commit 6ef73eb226
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9

View File

@ -99,8 +99,10 @@ make_setting_route!(
analytics.publish( analytics.publish(
"FilterableAttributes Updated".to_string(), "FilterableAttributes Updated".to_string(),
json!({ json!({
"total": setting.as_ref().map(|filter| filter.len()).unwrap_or(0), "filterable_attributes": {
"has_geo": setting.as_ref().map(|filter| filter.contains("_geo")).unwrap_or(false), "total": setting.as_ref().map(|filter| filter.len()).unwrap_or(0),
"has_geo": setting.as_ref().map(|filter| filter.contains("_geo")).unwrap_or(false),
}
}), }),
Some(req), Some(req),
); );
@ -119,8 +121,10 @@ make_setting_route!(
analytics.publish( analytics.publish(
"SortableAttributes Updated".to_string(), "SortableAttributes Updated".to_string(),
json!({ json!({
"total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0), "sortable_attributes": {
"has_geo": setting.as_ref().map(|sort| sort.contains("_geo")).unwrap_or(false), "total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0),
"has_geo": setting.as_ref().map(|sort| sort.contains("_geo")).unwrap_or(false),
},
}), }),
Some(req), Some(req),
); );
@ -138,7 +142,21 @@ make_setting_route!(
"/searchable-attributes", "/searchable-attributes",
Vec<String>, Vec<String>,
searchable_attributes, searchable_attributes,
"searchableAttributes" "searchableAttributes",
analytics,
|setting: &Option<Vec<String>>, req: &HttpRequest| {
use serde_json::json;
analytics.publish(
"SearchableAttributes Updated".to_string(),
json!({
"searchable_attributes": {
"total": setting.as_ref().map(|sort| sort.len()).unwrap_or(0),
},
}),
Some(req),
);
}
); );
make_setting_route!( make_setting_route!(