* Big speed-up of the job status page and the channel generation (such

[?]
Apr 3, 2009, 3:37 PM
SJN2QPWHFYKX7CJMW4XZHI2P2THH7MECZZIHQMCH6EKBZ45G3DOAC

Dependencies

  • [2] U7G4EEQC
  • [3] T2232OBS * Add some DB indices to make the /releases page much faster.
  • [4] DEMSSSB2 * Controller for jobs which inherits all actions in ListBuilds. So
  • [5] JLDUSNUO * Unify rendering of finished and scheduled builds.
  • [6] 2JQ7WEFM
  • [7] JRU2LRPZ
  • [8] UWVMQIAC * Refactoring.
  • [9] LBNVQXUB * Build the /build stuff in a separate controller.
  • [10] LVJKRTIK * Generate a Nix expression for the channel.
  • [11] CS7T2XFI
  • [12] ZRBXLKFO
  • [13] 3HZY24CX * Make jobsets viewable under
  • [14] 3E6IP3R3 * Add the name of the jobset to ReleaseSetJobs, otherwise we can't
  • [15] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [16] 7UJ5YV4V * Provide a channel for each project containing all the latest
  • [17] BHZXGT2H * Channels: provide an index page that lists all the packages in the
  • [18] AKAZKCR6 * At top-level and for each project, provide two channels: "latest"
  • [19] RI4S7SYT * Job status: show the active jobs.
  • [20] 2AUODJBT
  • [*] 5NO7NCKT * Refactoring.
  • [*] J5UVLXOK * Start of a basic Catalyst web interface.
  • [*] L2E6EVE2 * Merged the Build and Job tables.
  • [*] N22GPKYT * Put info about logs / build products in the DB.

Change contents

  • edit in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 13
    [4.44][4.0:37]()
    my $jobs = $c->stash->{allJobs};
  • replacement in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 14
    [4.69][4.69:170]()
    getLatestBuilds($c, ref $jobs eq "ARRAY" ? $jobs : scalar $jobs->search({active => 1}), {});
    [4.69]
    [4.330]
    [joinWithResultInfo($c, $c->stash->{jobStatus})->all];
  • replacement in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 35
    [4.823][4.823:882]()
    $c->stash->{builds} = [$c->stash->{allBuilds}->search(
    [4.823]
    [3.114]
    $c->stash->{builds} = [joinWithResultInfo($c, $c->stash->{allBuilds})->search(
  • replacement in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 37
    [3.141][3.141:337]()
    { join => 'resultInfo'
    , '+select' => ["resultInfo.buildstatus", "resultInfo.releasename"]
    , '+as' => ["buildstatus", "releasename"]
    , order_by => "timestamp DESC"
    [3.141]
    [3.337]
    { order_by => "timestamp DESC"
  • replacement in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 48
    [4.289][4.171:296]()
    getChannelData($c, getLatestBuilds($c, scalar $c->stash->{allJobs}->search({active => 1}), {buildStatus => 0}));
    [4.289]
    [4.386]
    getChannelData($c, scalar($c->stash->{latestSucceeded}));
  • replacement in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 52
    [4.514][4.514:577]()
    getChannelData($c, [$c->stash->{allBuilds}->all]);
    [4.514]
    [4.577]
    getChannelData($c, scalar($c->stash->{allBuilds}));
  • replacement in src/lib/Hydra/Base/Controller/NixChannel.pm at line 68
    [4.78][4.78:141]()
    return $build->resultInfo->releasename || $build->nixname;
    [4.78]
    [2.0]
    return $build->get_column('releasename') || $build->nixname;
  • replacement in src/lib/Hydra/Controller/Job.pm at line 33
    [4.419][4.297:476]()
    #$c->stash->{allJobs} = # !!! horribly hacky
    # $c->stash->{job}->jobset->jobs->search({name => $c->stash->{job}->name});
    $c->stash->{allJobs} = [$c->stash->{job}];
    [4.419]
    [4.799]
    $c->stash->{jobStatus} = $c->model('DB')->resultset('JobStatusForJob')
    ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name, $c->stash->{job}->name]});
    $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForJob')
    ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name, $c->stash->{job}->name]});
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 39
    [4.535][4.535:589]()
    $c->stash->{allJobs} = $c->stash->{jobset}->jobs;
    [4.535]
    [4.1029]
    $c->stash->{jobStatus} = $c->model('DB')->resultset('JobStatusForJobset')
    ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]});
    $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForJobset')
    ->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]});
  • replacement in src/lib/Hydra/Controller/Project.pm at line 173
    [4.1034][4.590:645]()
    $c->stash->{allJobs} = $c->stash->{project}->jobs;
    [4.1034]
    [4.1034]
    $c->stash->{jobStatus} = $c->model('DB')->resultset('JobStatusForProject')
    ->search({}, {bind => [$c->stash->{project}->name]});
    $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForProject')
    ->search({}, {bind => [$c->stash->{project}->name]});
  • replacement in src/lib/Hydra/Controller/Root.pm at line 228
    [4.9650][4.646:696]()
    $c->stash->{allJobs} = $c->model('DB::Jobs');
    [4.9650]
    [4.774]
    $c->stash->{jobStatus} = $c->model('DB')->resultset('JobStatus');
    $c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceeded');
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 10
    [4.125][4.562:620]()
    getBuild getBuildStats getLatestBuilds getChannelData
    [4.125]
    [4.9702]
    getBuild getBuildStats joinWithResultInfo getChannelData
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 44
    [4.10461][4.10461:10525](),[4.10525][4.697:735]()
    # Return the latest build for each job.
    sub getLatestBuilds {
    my ($c, $jobs, $extraAttrs) = @_;
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 45
    [4.10566][4.10566:10584]()
    my @res = ();
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 46
    [4.10585][4.736:783]()
    # !!! this could be done more efficiently.
    [4.10585]
    [4.783]
    # Add the releaseName and buildStatus attributes from the
    # BuildResultInfo table for each build.
    sub joinWithResultInfo {
    my ($c, $source) = @_;
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 51
    [4.784][4.784:1072](),[4.1072][3.1175:1417](),[3.1417][4.1156:1215](),[4.1156][4.1156:1215](),[4.1215][4.11075:11101](),[4.11075][4.11075:11101]()
    foreach my $job (ref $jobs eq "ARRAY" ? @{$jobs} : $jobs->all) {
    foreach my $system ($job->builds->search({}, {select => ['system'], distinct => 1})) {
    my ($build) = $job->builds->search(
    { finished => 1, system => $system->system, %$extraAttrs },
    { join => 'resultInfo', order_by => 'timestamp DESC', rows => 1
    , '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
    , '+as' => ["releasename", "buildstatus"]
    });
    push @res, $build if defined $build;
    }
    }
    return [@res];
    [4.784]
    [4.621]
    return $source->search(
    { },
    { join => 'resultInfo'
    , '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
    , '+as' => ["releasename", "buildstatus"]
    });
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 62
    [4.673]
    [4.673]
    my @builds2 = joinWithResultInfo($c, $builds)
    ->search_literal("exists (select 1 from buildproducts where build = me.id and type = 'nix-build')");
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 67
    [4.774][4.824:861](),[4.861][4.808:941](),[4.808][4.808:941]()
    foreach my $build (@{$builds}) {
    # !!! better do this in getLatestBuilds with a join.
    next unless $build->buildproducts->find({type => "nix-build"});
    [4.774]
    [4.941]
    foreach my $build (@builds2) {
  • edit in src/lib/Hydra/Schema/Builds.pm at line 104
    [24.3770]
    [24.3770]
    sub makeSource {
    my ($name, $query) = @_;
    my $source = __PACKAGE__->result_source_instance();
    my $new_source = $source->new($source);
    $new_source->source_name($name);
    $new_source->name(\ "($query)");
    Hydra::Schema->register_extra_source($name => $new_source);
    }
    sub makeQueries {
    my ($name, $constraint) = @_;
    makeSource('JobStatus' . $name, "select * from (select project, jobset, job, system, max(timestamp) timestamp from Builds where finished = 1 $constraint group by project, jobset, job, system) natural join Builds");
    makeSource('LatestSucceeded' . $name, "select * from (select project, jobset, job, system, max(timestamp) timestamp from Builds natural join BuildResultInfo where finished = 1 and buildStatus = 0 $constraint group by project, jobset, job, system) natural join Builds");
    }
  • edit in src/lib/Hydra/Schema/Builds.pm at line 121
    [24.3771]
    [23.6337]
    makeQueries('', "");
    makeQueries('ForProject', "and project = ?");
    makeQueries('ForJobset', "and project = ? and jobset = ?");
    makeQueries('ForJob', "and project = ? and jobset = ? and job = ?");
  • replacement in src/root/channel-contents.tt at line 59
    [4.4127][4.4127:4229]()
    <td><a href="[% uri %]"><tt>[% build.resultInfo.releasename || build.nixname %]</tt></a></td>
    [4.4127]
    [4.4229]
    <td><a href="[% uri %]"><tt>[% build.get_column('releasename') || build.nixname %]</tt></a></td>
  • edit in src/sql/hydra.sql at line 408
    [3.2358]
    create index IndexBuildsByTimestamp on Builds(timestamp);
    --create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system);