Merge pull request #654 from nlewo/lewo-search-by-hash

Allow to search builds by hash
This commit is contained in:
Eelco Dolstra 2019-06-13 14:36:29 +02:00 committed by GitHub
commit 2b4658b6ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

@ -422,11 +422,11 @@ sub search :Local Args(0) {
# 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" => trim($query) }, { "buildoutputs.path" => { ilike => "%$query%" } },
{ order_by => ["id desc"], join => ["buildoutputs"] } ) ]; { order_by => ["id desc"], join => ["buildoutputs"] } ) ];
$c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search( $c->stash->{buildsdrv} = [ $c->model('DB::Builds')->search(
{ "drvpath" => trim($query) }, { "drvpath" => { ilike => "%$query%" } },
{ order_by => ["id desc"] } ) ]; { order_by => ["id desc"] } ) ];
$c->stash->{resource} = { projects => $c->stash->{projects}, $c->stash->{resource} = { projects => $c->stash->{projects},

View file

@ -688,3 +688,9 @@ create index IndexBuildsOnKeep on Builds(keep) where keep = 1;
create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1; create index IndexJobsetEvalsOnJobsetId on JobsetEvals(project, jobset, id desc) where hasNewBuilds = 1;
create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null; create index IndexBuildsOnNotificationPendingSince on Builds(notificationPendingSince) where notificationPendingSince is not null;
#ifdef POSTGRESQL
-- Provide an index used by LIKE operator on builds.drvpath (search query)
CREATE EXTENSION pg_trgm;
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);
#endif

2
src/sql/upgrade-57.sql Normal file
View file

@ -0,0 +1,2 @@
CREATE EXTENSION pg_trgm;
CREATE INDEX IndexTrgmBuildsOnDrvpath ON builds USING gin (drvpath gin_trgm_ops);