mirror of
https://github.com/NixOS/hydra.git
synced 2024-10-17 16:37:26 -04:00
api: fix /eval/X/builds requiring 5*len(builds)+1 SQL queries
Prefetch related tables that get fetched as part of serialization to JSON. Drop the `jobsetevals` field since making it efficient is trickier (due to not using DBIx native relationships but instead a many_to_many through a custom table). There is likely a way we could keep it and make it efficient, but I'm not fluent enough in DBIx to know.
This commit is contained in:
parent
02e453fc8c
commit
cb10eef700
|
@ -188,7 +188,9 @@ sub store_paths : Chained('evalChain') PathPart('store-paths') Args(0) {
|
|||
# Return full info about all the builds in this evaluation.
|
||||
sub all_builds : Chained('evalChain') PathPart('builds') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
my @builds = $c->stash->{eval}->builds;
|
||||
my @builds = $c->stash->{eval}->builds
|
||||
->search({},
|
||||
{ prefetch => ['jobset', 'buildoutputs', 'buildproducts', 'buildmetrics'] });
|
||||
$self->status_ok(
|
||||
$c,
|
||||
entity => [@builds],
|
||||
|
|
|
@ -568,19 +568,14 @@ makeQueries('ForJobName', "and jobset_id = (select id from jobsets j where j.nam
|
|||
sub as_json {
|
||||
my ($self) = @_;
|
||||
|
||||
# After #1093 merges this can become $self->jobset;
|
||||
# However, with ->jobset being a column on master
|
||||
# it seems DBIX gets a it confused.
|
||||
my ($jobset) = $self->search_related('jobset')->first;
|
||||
|
||||
my $json = {
|
||||
id => $self->get_column('id'),
|
||||
finished => $self->get_column('finished'),
|
||||
timestamp => $self->get_column('timestamp'),
|
||||
starttime => $self->get_column('starttime'),
|
||||
stoptime => $self->get_column('stoptime'),
|
||||
project => $jobset->get_column('project'),
|
||||
jobset => $jobset->name,
|
||||
project => $self->jobset->get_column('project'),
|
||||
jobset => $self->jobset->get_column('name'),
|
||||
job => $self->get_column('job'),
|
||||
nixname => $self->get_column('nixname'),
|
||||
system => $self->get_column('system'),
|
||||
|
@ -588,7 +583,6 @@ sub as_json {
|
|||
buildstatus => $self->get_column('buildstatus'),
|
||||
releasename => $self->get_column('releasename'),
|
||||
drvpath => $self->get_column('drvpath'),
|
||||
jobsetevals => [ map { $_->id } $self->jobsetevals ],
|
||||
buildoutputs => { map { $_->name => $_ } $self->buildoutputs },
|
||||
buildproducts => { map { $_->productnr => $_ } $self->buildproducts },
|
||||
buildmetrics => { map { $_->name => $_ } $self->buildmetrics },
|
||||
|
|
|
@ -67,7 +67,6 @@ subtest "validating the JSON representation of a build" => sub {
|
|||
finished => 1,
|
||||
id => $aggregateBuild->id,
|
||||
job => "aggregate",
|
||||
jobsetevals => [ $aggregateBuild->jobsetevals->first->id ],
|
||||
nixname => "aggregate",
|
||||
priority => 100,
|
||||
releasename => undef,
|
||||
|
|
Loading…
Reference in a new issue