mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
log documents added
This commit is contained in:
parent
0b3e0a59cb
commit
1ed05c6c07
@ -8,9 +8,10 @@ use meilisearch_lib::milli::update::IndexDocumentsMethod;
|
||||
use meilisearch_lib::MeiliSearch;
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
use serde_json::{json, Value};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::analytics::Analytics;
|
||||
use crate::error::{MeilisearchHttpError, ResponseError};
|
||||
use crate::extractors::authentication::{policies::*, GuardedData};
|
||||
use crate::extractors::payload::Payload;
|
||||
@ -131,15 +132,29 @@ pub async fn add_documents(
|
||||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: Payload,
|
||||
req: HttpRequest,
|
||||
analytics: web::Data<&'static dyn Analytics>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
debug!("called with params: {:?}", params);
|
||||
let content_type = req
|
||||
.headers()
|
||||
.get("Content-type")
|
||||
.map(|s| s.to_str().unwrap_or("unkown"));
|
||||
let params = params.into_inner();
|
||||
|
||||
analytics.publish(
|
||||
"Documents Added".to_string(),
|
||||
json!({
|
||||
"payload_type": content_type,
|
||||
"with_primary_key": params.primary_key,
|
||||
"index_creation": meilisearch.get_index(path.index_uid.clone()).await.is_ok(),
|
||||
}),
|
||||
);
|
||||
|
||||
document_addition(
|
||||
req.headers()
|
||||
.get("Content-type")
|
||||
.map(|s| s.to_str().unwrap_or("unkown")),
|
||||
content_type,
|
||||
meilisearch,
|
||||
path.into_inner().index_uid,
|
||||
params.into_inner().primary_key,
|
||||
path.index_uid.clone(),
|
||||
params.primary_key,
|
||||
body,
|
||||
IndexDocumentsMethod::ReplaceDocuments,
|
||||
)
|
||||
|
@ -302,6 +302,7 @@ mod test {
|
||||
impl_is_policy! {A B}
|
||||
impl_is_policy! {A B C}
|
||||
impl_is_policy! {A B C D}
|
||||
impl_is_policy! {A B C D E}
|
||||
|
||||
/// Emits a compile error if a route doesn't have the correct authentication policy.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user