mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-02 01:55:03 +08:00
Introduce the Tasks Seen event when filtering
This commit is contained in:
parent
755b1a59a2
commit
a9fb5a4d50
@ -574,7 +574,7 @@ impl DocumentsAggregator {
|
|||||||
let content_type = request
|
let content_type = request
|
||||||
.headers()
|
.headers()
|
||||||
.get(CONTENT_TYPE)
|
.get(CONTENT_TYPE)
|
||||||
.map(|s| s.to_str().unwrap_or("unknown"))
|
.and_then(|s| s.to_str().ok())
|
||||||
.unwrap_or("unknown")
|
.unwrap_or("unknown")
|
||||||
.to_string();
|
.to_string();
|
||||||
ret.content_types.insert(content_type);
|
ret.content_types.insert(content_type);
|
||||||
@ -591,13 +591,13 @@ impl DocumentsAggregator {
|
|||||||
|
|
||||||
self.updated |= other.updated;
|
self.updated |= other.updated;
|
||||||
// we can't create a union because there is no `into_union` method
|
// we can't create a union because there is no `into_union` method
|
||||||
for user_agent in other.user_agents.into_iter() {
|
for user_agent in other.user_agents {
|
||||||
self.user_agents.insert(user_agent);
|
self.user_agents.insert(user_agent);
|
||||||
}
|
}
|
||||||
for primary_key in other.primary_keys.into_iter() {
|
for primary_key in other.primary_keys {
|
||||||
self.primary_keys.insert(primary_key);
|
self.primary_keys.insert(primary_key);
|
||||||
}
|
}
|
||||||
for content_type in other.content_types.into_iter() {
|
for content_type in other.content_types {
|
||||||
self.content_types.insert(content_type);
|
self.content_types.insert(content_type);
|
||||||
}
|
}
|
||||||
self.index_creation |= other.index_creation;
|
self.index_creation |= other.index_creation;
|
||||||
|
@ -25,7 +25,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct TaskFilterQuery {
|
pub struct TasksFilterQuery {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
type_: Option<CS<StarOr<TaskType>>>,
|
type_: Option<CS<StarOr<TaskType>>>,
|
||||||
status: Option<CS<StarOr<TaskStatus>>>,
|
status: Option<CS<StarOr<TaskStatus>>>,
|
||||||
@ -61,17 +61,11 @@ fn task_status_matches_events(status: &TaskStatus, events: &[TaskEvent]) -> bool
|
|||||||
|
|
||||||
async fn get_tasks(
|
async fn get_tasks(
|
||||||
meilisearch: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, MeiliSearch>,
|
meilisearch: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, MeiliSearch>,
|
||||||
params: web::Query<TaskFilterQuery>,
|
params: web::Query<TasksFilterQuery>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
analytics: web::Data<dyn Analytics>,
|
analytics: web::Data<dyn Analytics>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
analytics.publish(
|
let TasksFilterQuery {
|
||||||
"Tasks Seen".to_string(),
|
|
||||||
json!({ "per_task_uid": false }),
|
|
||||||
Some(&req),
|
|
||||||
);
|
|
||||||
|
|
||||||
let TaskFilterQuery {
|
|
||||||
type_,
|
type_,
|
||||||
status,
|
status,
|
||||||
index_uid,
|
index_uid,
|
||||||
@ -87,6 +81,16 @@ async fn get_tasks(
|
|||||||
let status: Option<Vec<_>> = status.and_then(fold_star_or);
|
let status: Option<Vec<_>> = status.and_then(fold_star_or);
|
||||||
let index_uid: Option<Vec<_>> = index_uid.and_then(fold_star_or);
|
let index_uid: Option<Vec<_>> = index_uid.and_then(fold_star_or);
|
||||||
|
|
||||||
|
analytics.publish(
|
||||||
|
"Tasks Seen".to_string(),
|
||||||
|
json!({
|
||||||
|
"filtered_by_index_uid": index_uid.as_ref().map_or(false, |v| !v.is_empty()),
|
||||||
|
"filtered_by_type": type_.as_ref().map_or(false, |v| !v.is_empty()),
|
||||||
|
"filtered_by_status": status.as_ref().map_or(false, |v| !v.is_empty()),
|
||||||
|
}),
|
||||||
|
Some(&req),
|
||||||
|
);
|
||||||
|
|
||||||
// Then we filter on potential indexes and make sure that the search filter
|
// Then we filter on potential indexes and make sure that the search filter
|
||||||
// restrictions are also applied.
|
// restrictions are also applied.
|
||||||
let indexes_filters = match index_uid {
|
let indexes_filters = match index_uid {
|
||||||
|
Loading…
Reference in New Issue
Block a user