mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
simplify the search batcher
This commit is contained in:
parent
6591acfdfa
commit
f9b14ca149
@ -205,7 +205,7 @@ mod segment {
|
|||||||
|
|
||||||
fn start_search(
|
fn start_search(
|
||||||
&'static self,
|
&'static self,
|
||||||
getter: impl Fn(&'static Self) -> &'static Mutex<SearchBatcher> + Send + Sync + 'static,
|
batcher: &'static Mutex<SearchBatcher>,
|
||||||
query: &SearchQuery,
|
query: &SearchQuery,
|
||||||
request: &HttpRequest,
|
request: &HttpRequest,
|
||||||
) {
|
) {
|
||||||
@ -262,7 +262,7 @@ mod segment {
|
|||||||
- 1;
|
- 1;
|
||||||
|
|
||||||
println!("Batching a search");
|
println!("Batching a search");
|
||||||
let mut search_batcher = getter(self).lock().await;
|
let mut search_batcher = batcher.lock().await;
|
||||||
user_agent.into_iter().for_each(|ua| {
|
user_agent.into_iter().for_each(|ua| {
|
||||||
search_batcher.user_agents.insert(ua);
|
search_batcher.user_agents.insert(ua);
|
||||||
});
|
});
|
||||||
@ -347,7 +347,7 @@ mod segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn start_get_search(&'static self, query: &SearchQuery, request: &HttpRequest) {
|
fn start_get_search(&'static self, query: &SearchQuery, request: &HttpRequest) {
|
||||||
self.start_search(|s| &s.get_search_batcher, query, request)
|
self.start_search(&self.get_search_batcher, query, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_get_search(&'static self, process_time: usize) {
|
fn end_get_search(&'static self, process_time: usize) {
|
||||||
@ -359,7 +359,7 @@ mod segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn start_post_search(&'static self, query: &SearchQuery, request: &HttpRequest) {
|
fn start_post_search(&'static self, query: &SearchQuery, request: &HttpRequest) {
|
||||||
self.start_search(|s| &s.post_search_batcher, query, request)
|
self.start_search(&self.post_search_batcher, query, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_post_search(&'static self, process_time: usize) {
|
fn end_post_search(&'static self, process_time: usize) {
|
||||||
@ -500,7 +500,7 @@ mod segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentsBatcher {
|
impl DocumentsBatcher {
|
||||||
pub fn into_event(mut self, user: &User, event_name: &str) -> Option<Track> {
|
pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> {
|
||||||
if self.updated {
|
if self.updated {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user