Skip to content

Commit

Permalink
[backend] support view=versrel in _result query
Browse files Browse the repository at this point in the history
This will be used to check if all the builds of a maintenance incident
have the same checkin counter.
  • Loading branch information
mlschroe committed Sep 9, 2015
1 parent bad3f33 commit f4b3f8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/backend/BSVerify.pm
Expand Up @@ -203,7 +203,7 @@ sub verify_prpa {

sub verify_resultview {
my $view = $_[0];
die("unknown view parameter: '$view'\n") if $view ne 'summary' && $view ne 'status' && $view ne 'binarylist' && $view ne 'stats';
die("unknown view parameter: '$view'\n") if $view ne 'summary' && $view ne 'status' && $view ne 'binarylist' && $view ne 'stats' && $view ne 'versrel';
}

sub verify_workerid {
Expand Down
1 change: 1 addition & 0 deletions src/backend/BSXML.pm
Expand Up @@ -591,6 +591,7 @@ our $buildstatus = [
'code',
'status', # obsolete, now code
'error', # obsolete, now details
'versrel', # for withversrel result call
[],
'details',

Expand Down
14 changes: 9 additions & 5 deletions src/backend/bs_repserver
Expand Up @@ -1004,12 +1004,12 @@ sub getjobstatus {

my $jobstatus = readxml("$jobsdir/$arch/$status->{'job'}:status", $BSXML::jobstatus, 1);
# not yet building
return ({}, $BSXML::jobstatus) unless $status && $status->{'status'} eq 'scheduled';
return ({}, $BSXML::jobstatus) unless $jobstatus;

# find last successful build
my @history = BSFileDB::fdb_getlast("$reporoot/$projid/$repoid/$arch/$packid/history", $historylay);
my $history = BSFileDB::fdb_getlast("$reporoot/$projid/$repoid/$arch/$packid/history", $historylay);
my $lastduration;
$lastduration = $history[0]->{duration} if @history > 0;
$lastduration = $history->{'duration'} if $history;
$jobstatus->{'lastduration'} = $lastduration if $lastduration;

return ($jobstatus, $BSXML::jobstatus);
Expand Down Expand Up @@ -2375,6 +2375,10 @@ sub getresult {
} else {
my $s = {'package' => $packid, 'code' => $code};
$s->{'details'} = $ps->{'packerror'}->{$packid} if !$cgi->{'lastbuild'} && $ps->{'packerror'}->{$packid};
if ($cgi->{'withversrel'}) {
my $history = BSFileDB::fdb_getlast("$reporoot/$prpa/$packid/history", $historylay) || {};
$s->{'versrel'} = $history->{'versrel'} if $history->{'versrel'};
}
push @{$sl->{'status'}}, $s;
}
if ($cgi->{'withbinarylist'}) {
Expand Down Expand Up @@ -4321,7 +4325,7 @@ my $dispatches = [
'PUT:/configuration' => \&putconfiguration,
'/configuration' => \&getconfiguration,

'/_result $prpa+ oldstate:md5? package* code:* lastbuild:bool? withbinarylist:bool? withstats:bool? summary:bool?' => \&getresult,
'/_result $prpa+ oldstate:md5? package* code:* lastbuild:bool? withbinarylist:bool? withstats:bool? summary:bool? withversrel:bool?' => \&getresult,
'POST:/_command $cmd: $prpa+ package* code:* wipe:*' => \&docommand,

'/serverstatus' => \&BSStdServer::serverstatus,
Expand All @@ -4334,7 +4338,7 @@ my $dispatches_ajax = [
'/build/$project/$repository/$arch/$package/_log nostream:bool? last:bool? start:intnum? end:num? view:?' => \&getlogfile,
'/build/$project/$repository/$arch/$package:package_repository view:? binary:filename* nosource:bool?' => \&getbinarylist,
'/build/$project/$repository/$arch/$package:package_repository/$filename view:?' => \&getbinary,
'/_result $prpa+ oldstate:md5? package* code:* withbinarylist:bool? withstats:bool? summary:bool?' => \&getresult,
'/_result $prpa+ oldstate:md5? package* code:* withbinarylist:bool? withstats:bool? summary:bool? withversrel:bool?' => \&getresult,
'/getbinaries $project $repository $arch binaries: nometa:bool? metaonly:bool?' => \&getbinaries,
'/getbinaryversions $project $repository $arch binaries: nometa:bool?' => \&getbinaryversions,
];
Expand Down
2 changes: 2 additions & 0 deletions src/backend/bs_srcserver
Expand Up @@ -6369,6 +6369,7 @@ sub getresult {
my %repoidfilter = map {$_ => 1} @{$cgi->{'repository'} || []};
my %archfilter = map {$_ => 1} @{$cgi->{'arch'} || []};
my %view = map {$_ => 1} @{$cgi->{'view'} || ['status']};
$view{'status'} = 1 if $view{'versrel'};
my %code = map {$_ => 1} @{$cgi->{'code'} || []};

if ($cgi->{'repository'}) {
Expand Down Expand Up @@ -6409,6 +6410,7 @@ sub getresult {
push @args, map {"code=$_"} @{$cgi->{'code'} || []};
push @args, 'withbinarylist' if $view{'binarylist'};
push @args, 'withstats' if $view{'stats'};
push @args, 'withversrel' if $view{'versrel'};
push @args, 'summary' if $view{'summary'} && !$view{'status'};
eval {
$ps = BSWatcher::rpc("$reposerver/_result", $BSXML::resultlist, @args);
Expand Down

0 comments on commit f4b3f8c

Please sign in to comment.