mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 05:30:16 +01:00
clippy + fmt
This commit is contained in:
parent
d65f055030
commit
2665c0099d
@ -22,6 +22,7 @@ impl SearchAggregator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MockAnalytics {
|
impl MockAnalytics {
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new(opt: &Opt) -> (Arc<dyn Analytics>, String) {
|
pub fn new(opt: &Opt) -> (Arc<dyn Analytics>, String) {
|
||||||
let user = find_user_id(&opt.db_path).unwrap_or_default();
|
let user = find_user_id(&opt.db_path).unwrap_or_default();
|
||||||
(Arc::new(Self), user)
|
(Arc::new(Self), user)
|
||||||
|
@ -119,11 +119,15 @@ impl super::Analytics for SegmentAnalytics {
|
|||||||
properties: send,
|
properties: send,
|
||||||
..Default::default()
|
..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) {
|
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) {
|
fn post_search(&self, aggregate: SearchAggregator) {
|
||||||
|
@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
let (analytics, user) = if !opt.no_analytics {
|
let (analytics, user) = if !opt.no_analytics {
|
||||||
analytics::SegmentAnalytics::new(&opt, &meilisearch).await
|
analytics::SegmentAnalytics::new(&opt, &meilisearch).await
|
||||||
} else {
|
} else {
|
||||||
analytics::MockAnalytics::new(&opt)
|
analytics::create_(&opt)
|
||||||
};
|
};
|
||||||
#[cfg(any(debug_assertions, not(feature = "analytics")))]
|
#[cfg(any(debug_assertions, not(feature = "analytics")))]
|
||||||
let (analytics, user) = analytics::MockAnalytics::new(&opt);
|
let (analytics, user) = analytics::MockAnalytics::new(&opt);
|
||||||
|
@ -16,7 +16,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
pub async fn create_dump(
|
pub async fn create_dump(
|
||||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
analytics.publish("Dump Created".to_string(), json!({}), Some(&req));
|
analytics.publish("Dump Created".to_string(), json!({}), Some(&req));
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ pub async fn add_documents(
|
|||||||
params: web::Query<UpdateDocumentsQuery>,
|
params: web::Query<UpdateDocumentsQuery>,
|
||||||
body: Payload,
|
body: Payload,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
debug!("called with params: {:?}", params);
|
debug!("called with params: {:?}", params);
|
||||||
let content_type = req
|
let content_type = req
|
||||||
@ -164,7 +164,7 @@ pub async fn update_documents(
|
|||||||
params: web::Query<UpdateDocumentsQuery>,
|
params: web::Query<UpdateDocumentsQuery>,
|
||||||
body: Payload,
|
body: Payload,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
debug!("called with params: {:?}", params);
|
debug!("called with params: {:?}", params);
|
||||||
let content_type = req
|
let content_type = req
|
||||||
|
@ -57,7 +57,7 @@ pub async fn create_index(
|
|||||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||||
body: web::Json<IndexCreateRequest>,
|
body: web::Json<IndexCreateRequest>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let body = body.into_inner();
|
let body = body.into_inner();
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ pub async fn update_index(
|
|||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
body: web::Json<UpdateIndexRequest>,
|
body: web::Json<UpdateIndexRequest>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
debug!("called with params: {:?}", body);
|
debug!("called with params: {:?}", body);
|
||||||
let body = body.into_inner();
|
let body = body.into_inner();
|
||||||
|
@ -111,7 +111,7 @@ pub async fn search_with_url_query(
|
|||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
params: web::Query<SearchQueryGet>,
|
params: web::Query<SearchQueryGet>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
debug!("called with params: {:?}", params);
|
debug!("called with params: {:?}", params);
|
||||||
let query: SearchQuery = params.into_inner().into();
|
let query: SearchQuery = params.into_inner().into();
|
||||||
@ -138,7 +138,7 @@ pub async fn search_with_post(
|
|||||||
path: web::Path<IndexParam>,
|
path: web::Path<IndexParam>,
|
||||||
params: web::Json<SearchQuery>,
|
params: web::Json<SearchQuery>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let query = params.into_inner();
|
let query = params.into_inner();
|
||||||
debug!("search called with params: {:?}", query);
|
debug!("search called with params: {:?}", query);
|
||||||
|
@ -43,7 +43,7 @@ macro_rules! make_setting_route {
|
|||||||
index_uid: actix_web::web::Path<String>,
|
index_uid: actix_web::web::Path<String>,
|
||||||
body: actix_web::web::Json<Option<$type>>,
|
body: actix_web::web::Json<Option<$type>>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
$analytics_var: web::Data<&'static dyn Analytics>,
|
$analytics_var: web::Data< dyn Analytics>,
|
||||||
) -> std::result::Result<HttpResponse, ResponseError> {
|
) -> std::result::Result<HttpResponse, ResponseError> {
|
||||||
let body = body.into_inner();
|
let body = body.into_inner();
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ pub async fn update_all(
|
|||||||
index_uid: web::Path<String>,
|
index_uid: web::Path<String>,
|
||||||
body: web::Json<Settings<Unchecked>>,
|
body: web::Json<Settings<Unchecked>>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<&'static dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let settings = body.into_inner();
|
let settings = body.into_inner();
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ impl Service {
|
|||||||
&self.meilisearch,
|
&self.meilisearch,
|
||||||
true,
|
true,
|
||||||
&self.options,
|
&self.options,
|
||||||
analytics::MockAnalytics::new(&self.options)
|
analytics::MockAnalytics::new(&self.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ impl Service {
|
|||||||
&self.meilisearch,
|
&self.meilisearch,
|
||||||
true,
|
true,
|
||||||
&self.options,
|
&self.options,
|
||||||
analytics::MockAnalytics::new(&self.options)
|
analytics::MockAnalytics::new(&self.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ impl Service {
|
|||||||
&self.meilisearch,
|
&self.meilisearch,
|
||||||
true,
|
true,
|
||||||
&self.options,
|
&self.options,
|
||||||
analytics::MockAnalytics::new(&self.options)
|
analytics::MockAnalytics::new(&self.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ impl Service {
|
|||||||
&self.meilisearch,
|
&self.meilisearch,
|
||||||
true,
|
true,
|
||||||
&self.options,
|
&self.options,
|
||||||
analytics::MockAnalytics::new(&self.options)
|
analytics::MockAnalytics::new(&self.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ impl Service {
|
|||||||
&self.meilisearch,
|
&self.meilisearch,
|
||||||
true,
|
true,
|
||||||
&self.options,
|
&self.options,
|
||||||
analytics::MockAnalytics::new(&self.options)
|
analytics::MockAnalytics::new(&self.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ async fn error_json_bad_content_type() {
|
|||||||
&server.service.meilisearch,
|
&server.service.meilisearch,
|
||||||
true,
|
true,
|
||||||
&server.service.options,
|
&server.service.options,
|
||||||
analytics::MockAnalytics::new(&server.service.options)
|
analytics::MockAnalytics::new(&server.service.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
for route in routes {
|
for route in routes {
|
||||||
|
@ -20,7 +20,7 @@ async fn add_documents_test_json_content_types() {
|
|||||||
&server.service.meilisearch,
|
&server.service.meilisearch,
|
||||||
true,
|
true,
|
||||||
&server.service.options,
|
&server.service.options,
|
||||||
analytics::MockAnalytics::new(&server.service.options)
|
analytics::MockAnalytics::new(&server.service.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
// post
|
// post
|
||||||
@ -65,7 +65,7 @@ async fn error_add_documents_test_bad_content_types() {
|
|||||||
&server.service.meilisearch,
|
&server.service.meilisearch,
|
||||||
true,
|
true,
|
||||||
&server.service.options,
|
&server.service.options,
|
||||||
analytics::MockAnalytics::new(&server.service.options)
|
analytics::MockAnalytics::new(&server.service.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
// post
|
// post
|
||||||
@ -132,7 +132,7 @@ async fn error_add_documents_test_no_content_type() {
|
|||||||
&server.service.meilisearch,
|
&server.service.meilisearch,
|
||||||
true,
|
true,
|
||||||
&server.service.options,
|
&server.service.options,
|
||||||
analytics::MockAnalytics::new(&server.service.options)
|
analytics::MockAnalytics::new(&server.service.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
// post
|
// post
|
||||||
|
Loading…
x
Reference in New Issue
Block a user