forked from lix-project/hydra
Merge pull request #853 from NixOS/search-limit-reqs
search: limit results to 50, default to 10
This commit is contained in:
commit
72e237fb2f
|
@ -13,6 +13,7 @@ use Nix::Config;
|
||||||
use Encode;
|
use Encode;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use List::Util qw[min max];
|
||||||
use List::MoreUtils qw{any};
|
use List::MoreUtils qw{any};
|
||||||
use Net::Prometheus;
|
use Net::Prometheus;
|
||||||
|
|
||||||
|
@ -438,12 +439,8 @@ sub search :Local Args(0) {
|
||||||
error($c, "Invalid character in query.")
|
error($c, "Invalid character in query.")
|
||||||
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
|
unless $query =~ /^[a-zA-Z0-9_\-\/.]+$/;
|
||||||
|
|
||||||
my $limit = trim $c->request->params->{"limit"};
|
my $limit = int(trim ($c->request->params->{"limit"} || "10"));
|
||||||
if ($limit eq "") {
|
$c->stash->{limit} = min(50, max(1, $limit));
|
||||||
$c->stash->{limit} = 500;
|
|
||||||
} else {
|
|
||||||
$c->stash->{limit} = $limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
||||||
{ -and =>
|
{ -and =>
|
||||||
|
|
Loading…
Reference in a new issue