From a2314cf436d172c870f5e6ad2ddb13db27987b35 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Mon, 24 Oct 2022 13:56:26 +0200 Subject: [PATCH] Update analytics --- .../src/analytics/segment_analytics.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/meilisearch-http/src/analytics/segment_analytics.rs b/meilisearch-http/src/analytics/segment_analytics.rs index 40679279a..6655a7f9b 100644 --- a/meilisearch-http/src/analytics/segment_analytics.rs +++ b/meilisearch-http/src/analytics/segment_analytics.rs @@ -271,8 +271,8 @@ impl Segment { } async fn run(mut self, meilisearch: MeiliSearch) { - const INTERVAL: Duration = Duration::from_secs(60); // one minute - // The first batch must be sent after one minute. + const INTERVAL: Duration = Duration::from_secs(60 * 60); // one hour + // The first batch must be sent after one hour. let mut interval = tokio::time::interval_at(tokio::time::Instant::now() + INTERVAL, INTERVAL); @@ -302,7 +302,7 @@ impl Segment { .push(Identify { context: Some(json!({ "app": { - "version": "prototype-pagination-4".to_string(), + "version": env!("CARGO_PKG_VERSION").to_string(), }, })), user: self.user.clone(), @@ -428,13 +428,14 @@ impl SearchAggregator { ret.max_terms_number = q.split_whitespace().count(); } - if query.limit.is_none() && query.offset.is_none() { - ret.max_limit = query.hits_per_page; - ret.max_offset = query.page.saturating_sub(1) * query.hits_per_page; + if query.hits_per_page.or(query.page).is_some() { + let limit = query.hits_per_page.unwrap_or_else(DEFAULT_SEARCH_LIMIT); + ret.max_limit = limit; + ret.max_offset = query.page.unwrap_or(1).saturating_sub(1) * limit; ret.finite_pagination = 1; } else { - ret.max_limit = query.limit.unwrap_or_else(DEFAULT_SEARCH_LIMIT); - ret.max_offset = query.offset.unwrap_or_default(); + ret.max_limit = query.limit; + ret.max_offset = query.offset; ret.finite_pagination = 0; }