Fix pagination analytics

This commit is contained in:
ManyTheFish 2022-08-08 15:20:03 +02:00
parent e35ea2ad55
commit 77e718214f

View File

@ -373,7 +373,7 @@ pub struct SearchAggregator {
// pagination
max_limit: usize,
max_offset: usize,
finite_pagination: bool,
finite_pagination: usize,
// formatting
highlight_pre_tag: bool,
@ -431,11 +431,11 @@ impl SearchAggregator {
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;
ret.finite_pagination = true;
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.finite_pagination = false;
ret.finite_pagination = 0;
}
ret.matching_strategy
@ -499,6 +499,7 @@ impl SearchAggregator {
// pagination
self.max_limit = self.max_limit.max(other.max_limit);
self.max_offset = self.max_offset.max(other.max_offset);
self.finite_pagination += other.finite_pagination;
self.highlight_pre_tag |= other.highlight_pre_tag;
self.highlight_post_tag |= other.highlight_post_tag;
@ -542,6 +543,7 @@ impl SearchAggregator {
"pagination": {
"max_limit": self.max_limit,
"max_offset": self.max_offset,
"finite_pagination": self.finite_pagination > self.total_received / 2,
},
"formatting": {
"highlight_pre_tag": self.highlight_pre_tag,