Avoid fetching Projects/Jobsets just to get the name column
In particular, doing a 'select * from Jobsets where ...' must be avoided, because the 'errormsg' column can be very big.
This commit is contained in:
parent
16811d3e78
commit
92d8d6baa5
|
@ -76,7 +76,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
|
||||||
sub jobsetToHash {
|
sub jobsetToHash {
|
||||||
my ($jobset) = @_;
|
my ($jobset) = @_;
|
||||||
return {
|
return {
|
||||||
project => $jobset->project->name,
|
project => $jobset->get_column('project'),
|
||||||
name => $jobset->name,
|
name => $jobset->name,
|
||||||
nrscheduled => $jobset->get_column("nrscheduled"),
|
nrscheduled => $jobset->get_column("nrscheduled"),
|
||||||
nrsucceeded => $jobset->get_column("nrsucceeded"),
|
nrsucceeded => $jobset->get_column("nrsucceeded"),
|
||||||
|
@ -206,12 +206,12 @@ sub scmdiff : Path('/api/scmdiff') Args(0) {
|
||||||
|
|
||||||
sub triggerJobset {
|
sub triggerJobset {
|
||||||
my ($self, $c, $jobset, $force) = @_;
|
my ($self, $c, $jobset, $force) = @_;
|
||||||
print STDERR "triggering jobset ", $jobset->project->name . ":" . $jobset->name, "\n";
|
print STDERR "triggering jobset ", $jobset->get_column('project') . ":" . $jobset->name, "\n";
|
||||||
txn_do($c->model('DB')->schema, sub {
|
txn_do($c->model('DB')->schema, sub {
|
||||||
$jobset->update({ triggertime => time });
|
$jobset->update({ triggertime => time });
|
||||||
$jobset->update({ forceeval => 1 }) if $force;
|
$jobset->update({ forceeval => 1 }) if $force;
|
||||||
});
|
});
|
||||||
push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->project->name . ":" . $jobset->name;
|
push @{$c->{stash}->{json}->{jobsetsTriggered}}, $jobset->get_column('project') . ":" . $jobset->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ sub release : Chained('evalChain') PathPart('release') Args(0) {
|
||||||
$releaseName ||= $_->releasename foreach @builds;
|
$releaseName ||= $_->releasename foreach @builds;
|
||||||
|
|
||||||
# If no release name has been defined by any of the builds, compose one of the project name and evaluation id
|
# If no release name has been defined by any of the builds, compose one of the project name and evaluation id
|
||||||
$releaseName = $eval->project->name."-".$eval->id unless defined $releaseName;
|
$releaseName = $eval->get_column('project') . "-" . $eval->id unless defined $releaseName;
|
||||||
|
|
||||||
my $release;
|
my $release;
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,9 @@ sub getNextBuild {
|
||||||
(my $nextBuild) = $c->model('DB::Builds')->search(
|
(my $nextBuild) = $c->model('DB::Builds')->search(
|
||||||
{ finished => 1
|
{ finished => 1
|
||||||
, system => $build->system
|
, system => $build->system
|
||||||
, project => $build->project->name
|
, project => $build->get_column('project')
|
||||||
, jobset => $build->jobset->name
|
, jobset => $build->get_column('jobset')
|
||||||
, job => $build->job->name
|
, job => $build->get_column('job')
|
||||||
, 'me.id' => { '>' => $build->id }
|
, 'me.id' => { '>' => $build->id }
|
||||||
}, {rows => 1, order_by => "me.id ASC"});
|
}, {rows => 1, order_by => "me.id ASC"});
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ sub getPreviousSuccessfulBuild {
|
||||||
(my $prevBuild) = $c->model('DB::Builds')->search(
|
(my $prevBuild) = $c->model('DB::Builds')->search(
|
||||||
{ finished => 1
|
{ finished => 1
|
||||||
, system => $build->system
|
, system => $build->system
|
||||||
, project => $build->project->name
|
, project => $build->get_column('project')
|
||||||
, jobset => $build->jobset->name
|
, jobset => $build->get_column('jobset')
|
||||||
, job => $build->job->name
|
, job => $build->get_column('job')
|
||||||
, buildstatus => 0
|
, buildstatus => 0
|
||||||
, 'me.id' => { '<' => $build->id }
|
, 'me.id' => { '<' => $build->id }
|
||||||
}, {rows => 1, order_by => "me.id DESC"});
|
}, {rows => 1, order_by => "me.id DESC"});
|
||||||
|
@ -289,7 +289,7 @@ sub parseJobsetName {
|
||||||
|
|
||||||
sub showJobName {
|
sub showJobName {
|
||||||
my ($build) = @_;
|
my ($build) = @_;
|
||||||
return $build->project->name . ":" . $build->jobset->name . ":" . $build->job->name;
|
return $build->get_column('project') . ":" . $build->get_column('jobset') . ":" . $build->get_column('job');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ sub buildFinished {
|
||||||
, dependents => [grep { $_->id != $build->id } @builds]
|
, dependents => [grep { $_->id != $build->id } @builds]
|
||||||
, baseurl => getBaseUrl($self->{config})
|
, baseurl => getBaseUrl($self->{config})
|
||||||
, showJobName => \&showJobName, showStatus => \&showStatus
|
, showJobName => \&showJobName, showStatus => \&showStatus
|
||||||
, showSystem => index($build->job->name, $build->system) == -1
|
, showSystem => index($build->get_column('job'), $build->system) == -1
|
||||||
, nrCommits => $nrCommits
|
, nrCommits => $nrCommits
|
||||||
, authorList => $authorList
|
, authorList => $authorList
|
||||||
};
|
};
|
||||||
|
@ -119,9 +119,9 @@ sub buildFinished {
|
||||||
|
|
||||||
sendEmail(
|
sendEmail(
|
||||||
$self->{config}, $to, $subject, $body,
|
$self->{config}, $to, $subject, $body,
|
||||||
[ 'X-Hydra-Project' => $build->project->name,
|
[ 'X-Hydra-Project' => $build->get_column('project'),
|
||||||
, 'X-Hydra-Jobset' => $build->jobset->name,
|
, 'X-Hydra-Jobset' => $build->get_column('jobset'),
|
||||||
, 'X-Hydra-Job' => $build->job->name,
|
, 'X-Hydra-Job' => $build->get_column('job'),
|
||||||
, 'X-Hydra-System' => $build->system
|
, 'X-Hydra-System' => $build->system
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ sub common {
|
||||||
state => $state,
|
state => $state,
|
||||||
target_url => "$baseurl/build/" . $b->id,
|
target_url => "$baseurl/build/" . $b->id,
|
||||||
description => "Hydra build #" . $b->id . " of $jobName",
|
description => "Hydra build #" . $b->id . " of $jobName",
|
||||||
name => "Hydra " . $b->job->name,
|
name => "Hydra " . $b->get_column('job'),
|
||||||
});
|
});
|
||||||
while (my $eval = $evals->next) {
|
while (my $eval = $evals->next) {
|
||||||
my $gitlabstatusInput = $eval->jobsetevalinputs->find({ name => "gitlab_status_repo" });
|
my $gitlabstatusInput = $eval->jobsetevalinputs->find({ name => "gitlab_status_repo" });
|
||||||
|
|
|
@ -59,7 +59,7 @@ sub buildFinished {
|
||||||
|
|
||||||
my $msg = "";
|
my $msg = "";
|
||||||
$msg .= "<img src='$img'/> ";
|
$msg .= "<img src='$img'/> ";
|
||||||
$msg .= "Job <a href='$baseurl/job/${\$build->project->name}/${\$build->jobset->name}/${\$build->job->name}'>${\showJobName($build)}</a>";
|
$msg .= "Job <a href='$baseurl/job/${\$build->get_column('project')}/${\$build->get_column('jobset')}/${\$build->get_column('job')}'>${\showJobName($build)}</a>";
|
||||||
$msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
|
$msg .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
|
||||||
$msg .= ": <a href='$baseurl/build/${\$build->id}'>" . showStatus($build) . "</a>";
|
$msg .= ": <a href='$baseurl/build/${\$build->id}'>" . showStatus($build) . "</a>";
|
||||||
|
|
||||||
|
|
|
@ -104,10 +104,10 @@ sub buildFinished {
|
||||||
my $tagSet = {
|
my $tagSet = {
|
||||||
status => toBuildStatusClass($b->buildstatus),
|
status => toBuildStatusClass($b->buildstatus),
|
||||||
result => toBuildStatusDetailed($b->buildstatus),
|
result => toBuildStatusDetailed($b->buildstatus),
|
||||||
project => $b->project->name,
|
project => $b->get_column('project'),
|
||||||
jobset => $b->jobset->name,
|
jobset => $b->get_column('jobset'),
|
||||||
repo => ($b->jobset->name =~ /^(.*)\.pr-/) ? $1 : $b->jobset->name,
|
repo => ($b->get_column('jobset') =~ /^(.*)\.pr-/) ? $1 : $b->get_column('jobset'),
|
||||||
job => $b->job->name,
|
job => $b->get_column('job'),
|
||||||
system => $b->system,
|
system => $b->system,
|
||||||
cached => $b->iscachedbuild ? "true" : "false",
|
cached => $b->iscachedbuild ? "true" : "false",
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,7 @@ sub buildFinished {
|
||||||
"danger";
|
"danger";
|
||||||
|
|
||||||
my $text = "";
|
my $text = "";
|
||||||
$text .= "Job <$baseurl/job/${\$build->project->name}/${\$build->jobset->name}/${\$build->job->name}|${\showJobName($build)}>";
|
$text .= "Job <$baseurl/job/${\$build->get_column('project')}/${\$build->get_column('jobset')}/${\$build->get_column('job')}|${\showJobName($build)}>";
|
||||||
$text .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
|
$text .= " (and ${\scalar @deps} others)" if scalar @deps > 0;
|
||||||
$text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build);
|
$text .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build);
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@ sub checkBuild {
|
||||||
# semantically unnecessary (because they're implied by
|
# semantically unnecessary (because they're implied by
|
||||||
# the eval), but they give a factor 1000 speedup on
|
# the eval), but they give a factor 1000 speedup on
|
||||||
# the Nixpkgs jobset with PostgreSQL.
|
# the Nixpkgs jobset with PostgreSQL.
|
||||||
{ project => $jobset->project->name, jobset => $jobset->name, job => $jobName,
|
{ project => $jobset->get_column('project'), jobset => $jobset->name, job => $jobName,
|
||||||
name => $firstOutputName, path => $firstOutputPath },
|
name => $firstOutputName, path => $firstOutputPath },
|
||||||
{ rows => 1, columns => ['id'], join => ['buildoutputs'] });
|
{ rows => 1, columns => ['id'], join => ['buildoutputs'] });
|
||||||
if (defined $prevBuild) {
|
if (defined $prevBuild) {
|
||||||
|
@ -489,7 +489,7 @@ sub checkBuild {
|
||||||
$buildMap->{$build->id} = { id => $build->id, jobName => $jobName, new => 1, drvPath => $drvPath };
|
$buildMap->{$build->id} = { id => $build->id, jobName => $jobName, new => 1, drvPath => $drvPath };
|
||||||
$$jobOutPathMap{$jobName . "\t" . $firstOutputPath} = $build->id;
|
$$jobOutPathMap{$jobName . "\t" . $firstOutputPath} = $build->id;
|
||||||
|
|
||||||
print STDERR "added build ${\$build->id} (${\$jobset->project->name}:${\$jobset->name}:$jobName)\n";
|
print STDERR "added build ${\$build->id} (${\$jobset->get_column('project')}:${\$jobset->name}:$jobName)\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
return $build;
|
return $build;
|
||||||
|
@ -531,7 +531,7 @@ sub sendJobsetErrorNotification() {
|
||||||
return if $jobset->project->owner->emailonerror == 0;
|
return if $jobset->project->owner->emailonerror == 0;
|
||||||
return if $errorMsg eq "";
|
return if $errorMsg eq "";
|
||||||
|
|
||||||
my $projectName = $jobset->project->name;
|
my $projectName = $jobset->get_column('project');
|
||||||
my $jobsetName = $jobset->name;
|
my $jobsetName = $jobset->name;
|
||||||
my $body = "Hi,\n"
|
my $body = "Hi,\n"
|
||||||
. "\n"
|
. "\n"
|
||||||
|
|
Loading…
Reference in a new issue