This commit is contained in:
parent
98c53156e6
commit
7b19257830
|
@ -180,6 +180,27 @@ sub releasesets :Local {
|
|||
}
|
||||
|
||||
|
||||
sub attrsToSQL {
|
||||
my ($attrs, $id) = @_;
|
||||
my @attrs = split / /, $attrs;
|
||||
|
||||
my $query = "1 = 1";
|
||||
|
||||
foreach my $attr (@attrs) {
|
||||
$attr =~ /^([\w-]+)=([\w-]*)$/ or die "invalid attribute in release set: $attr";
|
||||
my $name = $1;
|
||||
my $value = $2;
|
||||
# !!! Yes, this is horribly injection-prone... (though
|
||||
# name/value are filtered above). Should use SQL::Abstract,
|
||||
# but it can't deal with subqueries. At least we should use
|
||||
# placeholders.
|
||||
$query .= " and (select count(*) from buildinputs where build = $id and name = '$name' and value = '$value') = 1";
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
sub releases :Local {
|
||||
my ($self, $c, $projectName, $releaseName) = @_;
|
||||
$c->stash->{template} = 'releases.tt';
|
||||
|
@ -199,7 +220,10 @@ sub releases :Local {
|
|||
|
||||
my @primaryBuilds = $project->builds->search(
|
||||
{ attrname => $primaryJob->job, finished => 1 },
|
||||
{ join => 'resultInfo', order_by => "timestamp DESC", '+select' => ["resultInfo.releasename"], '+as' => ["releasename"] });
|
||||
{ join => 'resultInfo', order_by => "timestamp DESC"
|
||||
, '+select' => ["resultInfo.releasename"], '+as' => ["releasename"]
|
||||
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
||||
});
|
||||
|
||||
my @releases = ();
|
||||
|
||||
|
@ -220,7 +244,9 @@ sub releases :Local {
|
|||
($thisBuild) = $primaryBuild->dependentBuilds->search(
|
||||
{ attrname => $job->job, finished => 1 },
|
||||
{ join => 'resultInfo', rows => 1
|
||||
, order_by => ["buildstatus", "timestamp"] });
|
||||
, order_by => ["buildstatus", "timestamp"]
|
||||
, where => \ attrsToSQL($job->attrs, "build.id")
|
||||
});
|
||||
}
|
||||
|
||||
if ($job->mayfail != 1) {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
[% WRAPPER layout.tt title="Releases" %]
|
||||
[% WRAPPER layout.tt title="Release Set ‘$releaseSet.project.name:$releaseSet.name’" %]
|
||||
[% PROCESS common.tt %]
|
||||
[% USE HTML %]
|
||||
|
||||
<h1>Releases</h1>
|
||||
|
||||
<!-- <p>Description: [% releaseSet.description %]</p> -->
|
||||
<h1>Release Set <tt>[% releaseSet.project.name %]:[% releaseSet.name %]</tt></h1>
|
||||
|
||||
<table class="tablesorter">
|
||||
<thead>
|
||||
|
|
Loading…
Reference in a new issue