NYIIFA32IHFJIHC5IEAJKOCHXQ7QNR4SN3DDUUPM2GYL3SZNWFDAC
HCZ4B6VVBIQTUMEOJSH46BMXZ7GUHRBWU5W6X5IPXBEFP2P4GMEQC
LOFYJAHGCPDNP2IIEG6BPJCDK5QGZ3D4SJ2KT5ZZIDJ2KHJHVW5QC
U4TD3AIQXBJFFUORTMIC4IHZTVBORRKL2TZ2FSP4G665ECZOEMNAC
X46KWQFNQ4KFKCZHPT5UXKCFGV57WXUWPOHLUHQKIF3ZIQYGZBQQC
L7NUCXKSELV2XQBSETAN2KSXN5ONX3ESJDHZL6737LMK4KPGQANQC
WZZOOYCHQJJ6BWQPJFXULOBVSLZXPMOKM2YNA7TPEXUINLXFVI5AC
RHUAFTJAKUW654TNYHQYSSQ4PXFEEMDRRTLEPKCP3MOE7TWMTICQC
JWFZGHKPRS2JUAUQT7MRXMDPZOFBCJM4BRFT5D3WC7M6Y5JY5CVQC
EAN5HLLRVFRKBM23UO4YGODPWUJLOOKXDEPLQ572NA7UIFI4VVZQC
DE2DNCOIEVRA6OOSOSXI2USRPOWL4SC6XPCJFOUM54BS2ESCEWOAC
3PNG7NIBQQURUUPRVQXYL342OT7JUUYOMY2JJNP6YDX7SYJDZMYAC
D5QIOJGPKQJIYBUCSC3MFJ3TXLPNZ2XMI37GXMFRVRFWWR2VMTFAC
$c->stash->{stillSucceed} = [];
$c->stash->{stillFail} = [];
$c->stash->{nowSucceed} = [];
$c->stash->{nowFail} = [];
$c->stash->{new} = [];
$c->stash->{removed} = [];
$c->stash->{unfinished} = [];
$c->stash->{aborted} = [];
$c->stash->{failed} = [];
buildDiff(@builds, @builds2);
my $n = 0;
foreach my $build (@builds) {
my $aborted = $build->finished != 0 && ($build->buildstatus == 3 || $build->buildstatus == 4);
my $d;
my $found = 0;
while ($n < scalar(@builds2)) {
my $build2 = $builds2[$n];
my $d = cmpBuilds($build, $build2);
last if $d == -1;
if ($d == 0) {
$n++;
$found = 1;
if ($aborted) {
# do nothing
} elsif ($build->finished == 0 || $build2->finished == 0) {
push @{$c->stash->{unfinished}}, $build;
} elsif ($build->buildstatus == 0 && $build2->buildstatus == 0) {
push @{$c->stash->{stillSucceed}}, $build;
} elsif ($build->buildstatus != 0 && $build2->buildstatus != 0) {
push @{$c->stash->{stillFail}}, $build;
} elsif ($build->buildstatus == 0 && $build2->buildstatus != 0) {
push @{$c->stash->{nowSucceed}}, $build;
} elsif ($build->buildstatus != 0 && $build2->buildstatus == 0) {
push @{$c->stash->{nowFail}}, $build;
} else { die; }
last;
}
push @{$c->stash->{removed}}, { job => $build2->get_column('job'), system => $build2->get_column('system') };
$n++;
}
if ($aborted) {
push @{$c->stash->{aborted}}, $build;
} else {
push @{$c->stash->{new}}, $build if !$found;
}
if ($build->buildstatus != 0) {
push @{$c->stash->{failed}}, $build;
}
}
package Hydra::Helper::BuildDiff;
use utf8;
use strict;
use warnings;
use base 'Hydra::Base::Controller::NixChannel';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use List::SomeUtils qw(uniq);
our @ISA = qw(Exporter);
our @EXPORT = qw(
buildDiff
);
use Data::Dumper;
sub buildDiff {
my ($builds, $builds2) = @_;
my $ret = [
stillSucceed => [],
stillFail => [],
nowSucceed => [],
nowFail => [],
new => [],
removed => [],
unfinished => [],
aborted => [],
failed => [],
];
my $n = 0;
foreach my $build (@{$builds}) {
my $aborted = $build->finished != 0 && ($build->buildstatus == 3 || $build->buildstatus == 4);
my $d;
my $found = 0;
while ($n < scalar($builds2)) {
my $build2 = @{$builds2}[$n];
my $d = cmpBuilds($build, $build2);
last if $d == -1;
if ($d == 0) {
$n++;
$found = 1;
if ($aborted) {
# do nothing
} elsif ($build->finished == 0 || $build2->finished == 0) {
push @{$ret->{unfinished}}, $build;
} elsif ($build->buildstatus == 0 && $build2->buildstatus == 0) {
push @{$ret->{stillSucceed}}, $build;
} elsif ($build->buildstatus != 0 && $build2->buildstatus != 0) {
push @{$ret->{stillFail}}, $build;
} elsif ($build->buildstatus == 0 && $build2->buildstatus != 0) {
push @{$ret->{nowSucceed}}, $build;
} elsif ($build->buildstatus != 0 && $build2->buildstatus == 0) {
push @{$ret->{nowFail}}, $build;
} else { die; }
last;
}
push @{$ret->{removed}}, { job => $build2->get_column('job'), system => $build2->get_column('system') };
$n++;
}
if ($aborted) {
push @{$ret->{aborted}}, $build;
} else {
push @{$ret->{new}}, $build if !$found;
}
if ($build->buildstatus != 0) {
push @{$ret->{failed}}, $build;
}
}
return $ret;
}
1;