Eliminate duplicate getPreviousBuild functions

[?]
Jun 27, 2013, 4:08 PM
RPTSGIRCCSEDEBRB5H465A5JULJH5KFYAMR573SKNTPSJSCYEICQC

Dependencies

  • [2] DHMGSAEB * hydra: reinstate proper error for non existing build, Hydra/9
  • [3] LDICTHWY Use Template::Toolkit to generate email messages
  • [4] PPF3MVKH Improve email notifications status messages
  • [5] 5EQYVRWE Add a plugin mechanism
  • [6] 3PNG7NIB Remove trailing whitespace
  • [7] LBNVQXUB * Build the /build stuff in a separate controller.
  • [8] E6SL7QRU Omit the system type if it's part of the job name
  • [9] 3Y7AFJSS * Support linking to the latest job in a view for a specific platform, e.g.
  • [10] LUPEGYR7 Hydra: In case of failure, also show changes between last succesful build and the first failed build after this
  • [11] 5NO7NCKT * Refactoring.
  • [12] GJFYEU3S * Nix now stores logs by default as bzip2, make sure the build page uncompresses before showing.
  • [13] JUZVPV6S qualify id column in queries
  • [14] LGNML7VJ Don't use a prepared statement for the active build steps query
  • [15] BLVQGJ4L Use OO-style plugins
  • [16] QDJRQIFF If multiple dependent builds fail, send a single email
  • [17] PCKLFRT5 Support push notification of repository changes
  • [18] HQGXL4MX Add validation for project and jobset names
  • [19] LMETCA7G Cleanup
  • [20] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [21] JAUTUNGI bug fix
  • [22] XJRJ4J7M Add user registration
  • [23] KAZWI5G4 * hydra: buildpage, show changes since last build/successful build
  • [24] 2M7J26V4 inital version of links to diff in scm
  • [25] LSZLZHJY Allow users to edit their own settings
  • [*] 7UJ5YV4V * Provide a channel for each project containing all the latest
  • [*] N45RZUQ6 Reduce I/O in build listings by only fetching required columns
  • [*] CS7T2XFI

Change contents

  • replacement in src/lib/Hydra/Controller/Build.pm at line 27
    [2.95][5.0:71](),[5.466][5.0:71]()
    $c->stash->{prevBuild} = getPreviousBuild($c, $c->stash->{build});
    [2.95]
    [5.71]
    $c->stash->{prevBuild} = getPreviousBuild($c->stash->{build});
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 13
    [27.561]
    [5.3535]
    use feature qw/switch/;
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 22
    [5.187][5.1637:1657]()
    parseJobsetName
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 27
    [28.569]
    [29.180]
    parseJobsetName
    showJobName
    showStatus
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 45
    [5.295][5.295:321]()
    my ($c, $build) = @_;
    [5.295]
    [5.0]
    my ($build) = @_;
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 47
    [5.37][5.37:38](),[5.38][5.321:376](),[5.321][5.321:376]()
    (my $prevBuild) = $c->model('DB::Builds')->search(
    [5.37]
    [5.376]
    return $build->job->builds->search(
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 50
    [5.431][5.431:544]()
    , project => $build->project->name
    , jobset => $build->jobset->name
    , job => $build->job->name
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 51
    [5.2469][5.0:49](),[5.587][5.0:49](),[5.49][5.2470:2471](),[5.2471][5.638:661](),[5.638][5.638:661]()
    }, {rows => 1, order_by => "me.id DESC"});
    return $prevBuild;
    [5.2469]
    [5.208]
    , -not => { buildstatus => { -in => [4, 3]} }
    }, { rows => 1, order_by => "me.id DESC" })->single;
  • edit in src/lib/Hydra/Helper/CatalystUtils.pm at line 228
    [5.1814]
    [5.1814]
    }
    sub showJobName {
    my ($build) = @_;
    return $build->project->name . ":" . $build->jobset->name . ":" . $build->job->name;
    }
    sub showStatus {
    my ($build) = @_;
    my $status = "Failed";
    given ($build->buildstatus) {
    when (0) { $status = "Success"; }
    when (1) { $status = "Failed"; }
    when (2) { $status = "Dependency failed"; }
    when (4) { $status = "Cancelled"; }
    when (6) { $status = "Failed with output"; }
    }
    return $status;
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 5
    [5.28][5.77:101](),[5.77][5.77:101]()
    use feature qw/switch/;
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 15
    [5.34][5.331:333](),[5.331][5.331:333](),[5.333][3.15:54](),[3.54][5.385:413](),[5.385][5.385:413](),[5.413][3.55:89](),[3.89][5.440:482](),[5.440][5.440:482](),[5.482][4.0:41](),[4.41][5.547:643](),[5.547][5.547:643](),[5.643][4.42:95](),[4.95][5.643:669](),[5.643][5.643:669](),[5.669][3.90:223](),[3.223][5.35:37](),[5.669][5.35:37]()
    sub showStatus {
    my ($build) = @_;
    my $status = "Failed";
    given ($build->buildstatus) {
    when (0) { $status = "Success"; }
    when (1) { $status = "Failed"; }
    when (2) { $status = "Dependency failed"; }
    when (4) { $status = "Cancelled"; }
    when (6) { $status = "Failed with output"; }
    }
    return $status;
    }
    sub showJobName {
    my ($build) = @_;
    return $build->project->name . ":" . $build->jobset->name . ":" . $build->job->name;
    }
  • edit in src/lib/Hydra/Plugin/EmailNotification.pm at line 17
    [5.39][5.39:183](),[5.183][3.224:449](),[3.449][5.415:488](),[5.415][5.415:488]()
    sub getPrevBuild {
    my ($self, $build) = @_;
    return $self->{db}->resultset('Builds')->search(
    { project => $build->project->name
    , jobset => $build->jobset->name
    , job => $build->job->name
    , system => $build->system
    , finished => 1
    , id => { '<', $build->id }
    , -not => { buildstatus => { -in => [4, 3]} }
    }, { order_by => ["id DESC"], rows => 1 }
    )->single;
    }
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 54
    [5.861][5.861:910]()
    my $prevBuild = getPrevBuild($self, $b);
    [5.861]
    [5.910]
    my $prevBuild = getPreviousBuild($b);
  • replacement in src/lib/Hydra/Plugin/EmailNotification.pm at line 87
    [3.1209][3.1209:1281]()
    { build => $build, prevBuild => getPrevBuild($self, $build)
    [3.1209]
    [3.1281]
    { build => $build, prevBuild => getPreviousBuild($build)