Fixed cutoff and pagination
diff --git a/Makefile.PL b/Makefile.PL
index 4fcb944..52d2980 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -16,7 +16,7 @@
PREREQ_PM => {
'Mojolicious' => '5.00',
# 'Mojolicious::Plugin::Oro::Account' => 0.07,
- 'Mojolicious::Plugin::TagHelpers::Pagination' => 0.04,
+ 'Mojolicious::Plugin::TagHelpers::Pagination' => 0.05,
'Mojolicious::Plugin::Notifications' => 0.04,
'Mojolicious::Plugin::MailException' => 0.18,
'Mojolicious::Plugin::CHI' => 0.09,
diff --git a/lib/Korap/Plugin/KorapSearch.pm b/lib/Korap/Plugin/KorapSearch.pm
index c22b4b6..a65f1f9 100644
--- a/lib/Korap/Plugin/KorapSearch.pm
+++ b/lib/Korap/Plugin/KorapSearch.pm
@@ -170,12 +170,15 @@
$_->{'search.hits'} = map_matches($json->{matches});
};
- if ($json->{totalResults} && $json->{totalResults} > -1) {
- $c->app->log->debug('Cache total result');
- $c->chi->set('total-' . $cache_url => $json->{totalResults}, '30min');
+ # Learn results
+ unless ($total_results) {
+ if ($json->{totalResults} && $json->{totalResults} > -1) {
+ $c->app->log->debug('Cache total result');
+ $c->chi->set('total-' . $cache_url => $json->{totalResults}, '120min');
+ };
+ $c->stash('search.totalResults' => $json->{totalResults});
};
- $c->stash('search.totalResults' => $json->{totalResults});
if ($json->{warning}) {
$c->notify(warn => $json->{warning});
};
diff --git a/templates/search.html.ep b/templates/search.html.ep
index 077e93b..3fe6302 100644
--- a/templates/search.html.ep
+++ b/templates/search.html.ep
@@ -4,8 +4,8 @@
% unless (param 'snippet') {
<div style="clear: both">
% my $url = url_with->query(['p' => '{page}']);
-% my $pages = (stash('search.totalResults') / (stash('search.itemsPerPage') || 1));
-% $pages = $pages < 0 ? 0 : $pages;
+% my $pages;
+% $pages = stash('search.totalResults') == -1 ? -1 : (stash('search.totalResults') / (stash('search.itemsPerPage') || 1));
<div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div>
<p class="found">Found
% my $found = stash('search.totalResults');