diff --git a/meilisearch-http/src/analytics/mock_analytics.rs b/meilisearch-http/src/analytics/mock_analytics.rs index 486a10ac0..eb26add26 100644 --- a/meilisearch-http/src/analytics/mock_analytics.rs +++ b/meilisearch-http/src/analytics/mock_analytics.rs @@ -22,6 +22,7 @@ impl SearchAggregator { } impl MockAnalytics { + #[allow(clippy::new_ret_no_self)] pub fn new(opt: &Opt) -> (Arc, String) { let user = find_user_id(&opt.db_path).unwrap_or_default(); (Arc::new(Self), user) diff --git a/meilisearch-http/src/analytics/segment_analytics.rs b/meilisearch-http/src/analytics/segment_analytics.rs index f34bf4378..8fbea3eb8 100644 --- a/meilisearch-http/src/analytics/segment_analytics.rs +++ b/meilisearch-http/src/analytics/segment_analytics.rs @@ -119,11 +119,15 @@ impl super::Analytics for SegmentAnalytics { properties: send, ..Default::default() }; - let _ = self.sender.try_send(AnalyticsMsg::BatchMessage(event.into())); + let _ = self + .sender + .try_send(AnalyticsMsg::BatchMessage(event.into())); } fn get_search(&self, aggregate: SearchAggregator) { - let _ = self.sender.try_send(AnalyticsMsg::AggregateGetSearch(aggregate)); + let _ = self + .sender + .try_send(AnalyticsMsg::AggregateGetSearch(aggregate)); } fn post_search(&self, aggregate: SearchAggregator) { diff --git a/meilisearch-http/src/main.rs b/meilisearch-http/src/main.rs index 152c4bbcc..f831c0149 100644 --- a/meilisearch-http/src/main.rs +++ b/meilisearch-http/src/main.rs @@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> { let (analytics, user) = if !opt.no_analytics { analytics::SegmentAnalytics::new(&opt, &meilisearch).await } else { - analytics::MockAnalytics::new(&opt) + analytics::create_(&opt) }; #[cfg(any(debug_assertions, not(feature = "analytics")))] let (analytics, user) = analytics::MockAnalytics::new(&opt); diff --git a/meilisearch-http/src/routes/dump.rs b/meilisearch-http/src/routes/dump.rs index 849b8c654..00ff23584 100644 --- a/meilisearch-http/src/routes/dump.rs +++ b/meilisearch-http/src/routes/dump.rs @@ -16,7 +16,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { pub async fn create_dump( meilisearch: GuardedData, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { analytics.publish("Dump Created".to_string(), json!({}), Some(&req)); diff --git a/meilisearch-http/src/routes/indexes/documents.rs b/meilisearch-http/src/routes/indexes/documents.rs index d0e81e3da..22a8d5b60 100644 --- a/meilisearch-http/src/routes/indexes/documents.rs +++ b/meilisearch-http/src/routes/indexes/documents.rs @@ -132,7 +132,7 @@ pub async fn add_documents( params: web::Query, body: Payload, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { debug!("called with params: {:?}", params); let content_type = req @@ -164,7 +164,7 @@ pub async fn update_documents( params: web::Query, body: Payload, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { debug!("called with params: {:?}", params); let content_type = req diff --git a/meilisearch-http/src/routes/indexes/mod.rs b/meilisearch-http/src/routes/indexes/mod.rs index 81f937013..4a4fcd250 100644 --- a/meilisearch-http/src/routes/indexes/mod.rs +++ b/meilisearch-http/src/routes/indexes/mod.rs @@ -57,7 +57,7 @@ pub async fn create_index( meilisearch: GuardedData, body: web::Json, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { let body = body.into_inner(); @@ -101,7 +101,7 @@ pub async fn update_index( path: web::Path, body: web::Json, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { debug!("called with params: {:?}", body); let body = body.into_inner(); diff --git a/meilisearch-http/src/routes/indexes/search.rs b/meilisearch-http/src/routes/indexes/search.rs index f82f231f3..5f7a91673 100644 --- a/meilisearch-http/src/routes/indexes/search.rs +++ b/meilisearch-http/src/routes/indexes/search.rs @@ -111,7 +111,7 @@ pub async fn search_with_url_query( path: web::Path, params: web::Query, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { debug!("called with params: {:?}", params); let query: SearchQuery = params.into_inner().into(); @@ -138,7 +138,7 @@ pub async fn search_with_post( path: web::Path, params: web::Json, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { let query = params.into_inner(); debug!("search called with params: {:?}", query); diff --git a/meilisearch-http/src/routes/indexes/settings.rs b/meilisearch-http/src/routes/indexes/settings.rs index bccb1640c..8f9b9f14b 100644 --- a/meilisearch-http/src/routes/indexes/settings.rs +++ b/meilisearch-http/src/routes/indexes/settings.rs @@ -43,7 +43,7 @@ macro_rules! make_setting_route { index_uid: actix_web::web::Path, body: actix_web::web::Json>, req: HttpRequest, - $analytics_var: web::Data<&'static dyn Analytics>, + $analytics_var: web::Data< dyn Analytics>, ) -> std::result::Result { let body = body.into_inner(); @@ -230,7 +230,7 @@ pub async fn update_all( index_uid: web::Path, body: web::Json>, req: HttpRequest, - analytics: web::Data<&'static dyn Analytics>, + analytics: web::Data, ) -> Result { let settings = body.into_inner(); diff --git a/meilisearch-http/tests/common/service.rs b/meilisearch-http/tests/common/service.rs index 299769107..a15525fee 100644 --- a/meilisearch-http/tests/common/service.rs +++ b/meilisearch-http/tests/common/service.rs @@ -15,7 +15,7 @@ impl Service { &self.meilisearch, true, &self.options, - analytics::MockAnalytics::new(&self.options) + analytics::MockAnalytics::new(&self.options).0 )) .await; @@ -41,7 +41,7 @@ impl Service { &self.meilisearch, true, &self.options, - analytics::MockAnalytics::new(&self.options) + analytics::MockAnalytics::new(&self.options).0 )) .await; @@ -63,7 +63,7 @@ impl Service { &self.meilisearch, true, &self.options, - analytics::MockAnalytics::new(&self.options) + analytics::MockAnalytics::new(&self.options).0 )) .await; @@ -81,7 +81,7 @@ impl Service { &self.meilisearch, true, &self.options, - analytics::MockAnalytics::new(&self.options) + analytics::MockAnalytics::new(&self.options).0 )) .await; @@ -102,7 +102,7 @@ impl Service { &self.meilisearch, true, &self.options, - analytics::MockAnalytics::new(&self.options) + analytics::MockAnalytics::new(&self.options).0 )) .await; diff --git a/meilisearch-http/tests/content_type.rs b/meilisearch-http/tests/content_type.rs index 79c497bb7..481b12bf1 100644 --- a/meilisearch-http/tests/content_type.rs +++ b/meilisearch-http/tests/content_type.rs @@ -41,7 +41,7 @@ async fn error_json_bad_content_type() { &server.service.meilisearch, true, &server.service.options, - analytics::MockAnalytics::new(&server.service.options) + analytics::MockAnalytics::new(&server.service.options).0 )) .await; for route in routes { diff --git a/meilisearch-http/tests/documents/add_documents.rs b/meilisearch-http/tests/documents/add_documents.rs index 9e55ef2bd..e9fdf7233 100644 --- a/meilisearch-http/tests/documents/add_documents.rs +++ b/meilisearch-http/tests/documents/add_documents.rs @@ -20,7 +20,7 @@ async fn add_documents_test_json_content_types() { &server.service.meilisearch, true, &server.service.options, - analytics::MockAnalytics::new(&server.service.options) + analytics::MockAnalytics::new(&server.service.options).0 )) .await; // post @@ -65,7 +65,7 @@ async fn error_add_documents_test_bad_content_types() { &server.service.meilisearch, true, &server.service.options, - analytics::MockAnalytics::new(&server.service.options) + analytics::MockAnalytics::new(&server.service.options).0 )) .await; // post @@ -132,7 +132,7 @@ async fn error_add_documents_test_no_content_type() { &server.service.meilisearch, true, &server.service.options, - analytics::MockAnalytics::new(&server.service.options) + analytics::MockAnalytics::new(&server.service.options).0 )) .await; // post