From 7524bfc07fe99304644363ce0979068839346039 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Wed, 13 Oct 2021 14:10:22 +0200 Subject: [PATCH] log the all settings updated route --- .../src/routes/indexes/settings.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/meilisearch-http/src/routes/indexes/settings.rs b/meilisearch-http/src/routes/indexes/settings.rs index 7e6033180..96b8577ce 100644 --- a/meilisearch-http/src/routes/indexes/settings.rs +++ b/meilisearch-http/src/routes/indexes/settings.rs @@ -4,7 +4,9 @@ use actix_web::{web, HttpResponse}; use meilisearch_lib::index::{Settings, Unchecked}; use meilisearch_lib::index_controller::Update; use meilisearch_lib::MeiliSearch; +use serde_json::json; +use crate::analytics::Analytics; use crate::error::ResponseError; use crate::extractors::authentication::{policies::*, GuardedData}; @@ -154,9 +156,27 @@ pub async fn update_all( meilisearch: GuardedData, index_uid: web::Path, body: web::Json>, + analytics: web::Data<&'static dyn Analytics>, ) -> Result { let settings = body.into_inner(); + analytics.publish( + "Settings Updated".to_string(), + json!({ + "ranking_rules": { + "sort_position": settings.ranking_rules.as_ref().set().map(|sort| sort.iter().filter(|s| s.contains(":")).count()), + }, + "sortable_attributes": { + "total": settings.sortable_attributes.as_ref().set().map(|sort| sort.len()), + "has_geo": settings.sortable_attributes.as_ref().set().map(|sort| sort.iter().any(|s| s == "_geo")).unwrap_or(false), + }, + "filterable_attributes": { + "total": settings.filterable_attributes.as_ref().set().map(|filter| filter.len()), + "has_geo": settings.filterable_attributes.as_ref().set().map(|filter| filter.iter().any(|s| s == "_geo")).unwrap_or(false), + }, + }), + ); + let update = Update::Settings(settings); let update_result = meilisearch .register_update(index_uid.into_inner(), update, true)