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:
Eelco Dolstra 2019-08-13 17:42:19 +02:00
parent 16811d3e78
commit 92d8d6baa5
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
9 changed files with 25 additions and 25 deletions

View file

@ -76,7 +76,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
sub jobsetToHash {
my ($jobset) = @_;
return {
project => $jobset->project->name,
project => $jobset->get_column('project'),
name => $jobset->name,
nrscheduled => $jobset->get_column("nrscheduled"),
nrsucceeded => $jobset->get_column("nrsucceeded"),
@ -206,12 +206,12 @@ sub scmdiff : Path('/api/scmdiff') Args(0) {
sub triggerJobset {
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 {
$jobset->update({ triggertime => time });
$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;
}

View file

@ -142,7 +142,7 @@ sub release : Chained('evalChain') PathPart('release') Args(0) {
$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
$releaseName = $eval->project->name."-".$eval->id unless defined $releaseName;
$releaseName = $eval->get_column('project') . "-" . $eval->id unless defined $releaseName;
my $release;

View file

@ -60,9 +60,9 @@ sub getNextBuild {
(my $nextBuild) = $c->model('DB::Builds')->search(
{ finished => 1
, system => $build->system
, project => $build->project->name
, jobset => $build->jobset->name
, job => $build->job->name
, project => $build->get_column('project')
, jobset => $build->get_column('jobset')
, job => $build->get_column('job')
, 'me.id' => { '>' => $build->id }
}, {rows => 1, order_by => "me.id ASC"});
@ -77,9 +77,9 @@ sub getPreviousSuccessfulBuild {
(my $prevBuild) = $c->model('DB::Builds')->search(
{ finished => 1
, system => $build->system
, project => $build->project->name
, jobset => $build->jobset->name
, job => $build->job->name
, project => $build->get_column('project')
, jobset => $build->get_column('jobset')
, job => $build->get_column('job')
, buildstatus => 0
, 'me.id' => { '<' => $build->id }
}, {rows => 1, order_by => "me.id DESC"});
@ -289,7 +289,7 @@ sub parseJobsetName {
sub showJobName {
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');
}

View file

@ -100,7 +100,7 @@ sub buildFinished {
, dependents => [grep { $_->id != $build->id } @builds]
, baseurl => getBaseUrl($self->{config})
, showJobName => \&showJobName, showStatus => \&showStatus
, showSystem => index($build->job->name, $build->system) == -1
, showSystem => index($build->get_column('job'), $build->system) == -1
, nrCommits => $nrCommits
, authorList => $authorList
};
@ -119,9 +119,9 @@ sub buildFinished {
sendEmail(
$self->{config}, $to, $subject, $body,
[ 'X-Hydra-Project' => $build->project->name,
, 'X-Hydra-Jobset' => $build->jobset->name,
, 'X-Hydra-Job' => $build->job->name,
[ 'X-Hydra-Project' => $build->get_column('project'),
, 'X-Hydra-Jobset' => $build->get_column('jobset'),
, 'X-Hydra-Job' => $build->get_column('job'),
, 'X-Hydra-System' => $build->system
]);
}

View file

@ -55,7 +55,7 @@ sub common {
state => $state,
target_url => "$baseurl/build/" . $b->id,
description => "Hydra build #" . $b->id . " of $jobName",
name => "Hydra " . $b->job->name,
name => "Hydra " . $b->get_column('job'),
});
while (my $eval = $evals->next) {
my $gitlabstatusInput = $eval->jobsetevalinputs->find({ name => "gitlab_status_repo" });

View file

@ -59,7 +59,7 @@ sub buildFinished {
my $msg = "";
$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 .= ": <a href='$baseurl/build/${\$build->id}'>" . showStatus($build) . "</a>";

View file

@ -104,10 +104,10 @@ sub buildFinished {
my $tagSet = {
status => toBuildStatusClass($b->buildstatus),
result => toBuildStatusDetailed($b->buildstatus),
project => $b->project->name,
jobset => $b->jobset->name,
repo => ($b->jobset->name =~ /^(.*)\.pr-/) ? $1 : $b->jobset->name,
job => $b->job->name,
project => $b->get_column('project'),
jobset => $b->get_column('jobset'),
repo => ($b->get_column('jobset') =~ /^(.*)\.pr-/) ? $1 : $b->get_column('jobset'),
job => $b->get_column('job'),
system => $b->system,
cached => $b->iscachedbuild ? "true" : "false",
};

View file

@ -81,7 +81,7 @@ sub buildFinished {
"danger";
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 .= ": <$baseurl/build/${\$build->id}|" . showStatus($build) . ">". " in " . renderDuration($build);

View file

@ -438,7 +438,7 @@ sub checkBuild {
# semantically unnecessary (because they're implied by
# the eval), but they give a factor 1000 speedup on
# 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 },
{ rows => 1, columns => ['id'], join => ['buildoutputs'] });
if (defined $prevBuild) {
@ -489,7 +489,7 @@ sub checkBuild {
$buildMap->{$build->id} = { id => $build->id, jobName => $jobName, new => 1, drvPath => $drvPath };
$$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;
@ -531,7 +531,7 @@ sub sendJobsetErrorNotification() {
return if $jobset->project->owner->emailonerror == 0;
return if $errorMsg eq "";
my $projectName = $jobset->project->name;
my $projectName = $jobset->get_column('project');
my $jobsetName = $jobset->name;
my $body = "Hi,\n"
. "\n"