Allow to search builds by hash

Currently, a full store path has to be provided to search in
builds. This patch permits to search jobs with a output path or
derivation hash.

Usecase: we are building Docker images with Hydra. The tag of the
Docker image is the hash of the image output path. This patch would
allow us to find back the build job from the tag of a running
container image.
This commit is contained in:
Antoine Eiche 2019-06-04 09:39:04 +02:00
parent 1be7de15a8
commit 778fc03570

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},