forked from lix-project/hydra
search: limit queries to 20s
Even 20s is really long, but it cuts off queries which are today running for 500+s.
This commit is contained in:
parent
4f308b1f2f
commit
91e63fb7da
|
@ -442,50 +442,53 @@ sub search :Local Args(0) {
|
||||||
my $limit = int(trim ($c->request->params->{"limit"} || "10"));
|
my $limit = int(trim ($c->request->params->{"limit"} || "10"));
|
||||||
$c->stash->{limit} = min(50, max(1, $limit));
|
$c->stash->{limit} = min(50, max(1, $limit));
|
||||||
|
|
||||||
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
$c->model('DB')->schema->txn_do(sub {
|
||||||
{ -and =>
|
$c->model('DB')->schema->storage->dbh->do("SET LOCAL statement_timeout = 20000");
|
||||||
[ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }
|
$c->stash->{projects} = [ $c->model('DB::Projects')->search(
|
||||||
, { hidden => 0 }
|
{ -and =>
|
||||||
]
|
[ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }
|
||||||
},
|
, { hidden => 0 }
|
||||||
{ order_by => ["name"] } ) ];
|
]
|
||||||
|
},
|
||||||
|
{ order_by => ["name"] } ) ];
|
||||||
|
|
||||||
$c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search(
|
$c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search(
|
||||||
{ -and =>
|
{ -and =>
|
||||||
[ { -or => [ "me.name" => { ilike => "%$query%" }, "me.description" => { ilike => "%$query%" } ] }
|
[ { -or => [ "me.name" => { ilike => "%$query%" }, "me.description" => { ilike => "%$query%" } ] }
|
||||||
, { "project.hidden" => 0, "me.hidden" => 0 }
|
, { "project.hidden" => 0, "me.hidden" => 0 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ order_by => ["project", "name"], join => ["project"] } ) ];
|
{ order_by => ["project", "name"], join => ["project"] } ) ];
|
||||||
|
|
||||||
$c->stash->{jobs} = [ $c->model('DB::Builds')->search(
|
$c->stash->{jobs} = [ $c->model('DB::Builds')->search(
|
||||||
{ "job" => { ilike => "%$query%" }
|
{ "job" => { ilike => "%$query%" }
|
||||||
, "project.hidden" => 0
|
, "project.hidden" => 0
|
||||||
, "jobset.hidden" => 0
|
, "jobset.hidden" => 0
|
||||||
, iscurrent => 1
|
, iscurrent => 1
|
||||||
},
|
},
|
||||||
{ order_by => ["project", "jobset", "job"], join => ["project", "jobset"]
|
{ order_by => ["project", "jobset", "job"], join => ["project", "jobset"]
|
||||||
, rows => $c->stash->{limit} + 1
|
, rows => $c->stash->{limit} + 1
|
||||||
} )
|
} )
|
||||||
];
|
];
|
||||||
|
|
||||||
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
|
# Perform build search in separate queries to prevent seq scan on buildoutputs table.
|
||||||
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
|
$c->stash->{builds} = [ $c->model('DB::Builds')->search(
|
||||||
{ "buildoutputs.path" => { ilike => "%$query%" } },
|
{ "buildoutputs.path" => { ilike => "%$query%" } },
|
||||||
{ order_by => ["id desc"], join => ["buildoutputs"]
|
{ order_by => ["id desc"], join => ["buildoutputs"]
|
||||||
, rows => $c->stash->{limit}
|
, rows => $c->stash->{limit}
|
||||||
} ) ];
|
} ) ];
|
||||||
|
|
||||||
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
|
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
|
||||||
{ "drvpath" => { ilike => "%$query%" } },
|
{ "drvpath" => { ilike => "%$query%" } },
|
||||||
{ order_by => ["id desc"]
|
{ order_by => ["id desc"]
|
||||||
, rows => $c->stash->{limit}
|
, rows => $c->stash->{limit}
|
||||||
} ) ];
|
} ) ];
|
||||||
|
|
||||||
$c->stash->{resource} = { projects => $c->stash->{projects},
|
$c->stash->{resource} = { projects => $c->stash->{projects},
|
||||||
jobsets => $c->stash->{jobsets},
|
jobsets => $c->stash->{jobsets},
|
||||||
builds => $c->stash->{builds},
|
builds => $c->stash->{builds},
|
||||||
buildsdrv => $c->stash->{buildsdrv} };
|
buildsdrv => $c->stash->{buildsdrv} };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub serveLogFile {
|
sub serveLogFile {
|
||||||
|
|
Loading…
Reference in a new issue