+sub get_bug_statuses {
+ state $spec =
+ {bug => {type => SCALAR|ARRAYREF,
+ },
+ status => {type => HASHREF,
+ optional => 1,
+ },
+ bug_index => {type => OBJECT,
+ optional => 1,
+ },
+ version => {type => SCALAR|ARRAYREF,
+ optional => 1,
+ },
+ dist => {type => SCALAR|ARRAYREF,
+ optional => 1,
+ },
+ arch => {type => SCALAR|ARRAYREF,
+ optional => 1,
+ },
+ bugusertags => {type => HASHREF,
+ optional => 1,
+ },
+ sourceversions => {type => ARRAYREF,
+ optional => 1,
+ },
+ indicatesource => {type => BOOLEAN,
+ default => 1,
+ },
+ binary_to_source_cache => {type => HASHREF,
+ optional => 1,
+ },
+ schema => {type => OBJECT,
+ optional => 1,
+ },
+ };
+ my %param = validate_with(params => \@_,
+ spec => $spec,
+ );
+ my %status;
+ my %statuses;
+ if (defined $param{schema}) {
+ my @bug_statuses =
+ $param{schema}->resultset('BugStatus')->
+ search_rs({id => [make_list($param{bug})]},
+ {result_class => 'DBIx::Class::ResultClass::HashRefInflator'})->
+ all();
+ for my $bug_status (@bug_statuses) {
+ $statuses{$bug_status->{bug_num}} =
+ $bug_status;
+ for my $field (qw(blocks blockedby done),
+ qw(tags mergedwith)
+ ) {
+ $bug_status->{$field} //='';
+ }
+ $bug_status->{keywords} =
+ $bug_status->{tags};
+ $bug_status->{log_modified} =
+ DateTime::Format::Pg->
+ parse_datetime($bug_status->{log_modified})->
+ epoch;
+ $bug_status->{date} =
+ DateTime::Format::Pg->
+ parse_datetime($bug_status->{date})->
+ epoch;
+ $bug_status->{last_modified} =
+ DateTime::Format::Pg->
+ parse_datetime($bug_status->{last_modified})->
+ epoch;
+ $bug_status->{location} = $bug_status->{archived}?'archive':'db-h';
+ for my $field (qw(found_versions fixed_versions found_date fixed_date)) {
+ $bug_status->{$field} = [split ' ', $bug_status->{$field} // ''];
+ }
+ for my $field (qw(found fixed)) {
+ # create the found/fixed hashes which indicate when a
+ # particular version was marked found or marked fixed.
+ @{$bug_status->{$field}}{@{$bug_status->{"${field}_versions"}}} =
+ (('') x (@{$bug_status->{"${field}_versions"}} -
+ @{$bug_status->{"${field}_date"}}),
+ @{$bug_status->{"${field}_date"}});
+ }
+ $bug_status->{id} = $bug_status->{bug_num};
+ }
+ } else {
+ for my $bug (make_list($param{bug})) {
+ if (defined $param{bug_index} and
+ exists $param{bug_index}{$bug}) {
+ my %status = %{$param{bug_index}{$bug}};
+ $status{pending} = $status{status};
+ $status{id} = $bug;
+ $statuses{$bug} = \%status;
+ }
+ elsif (defined $param{status} and
+ $param{status}{bug_num} == $bug
+ ) {
+ $statuses{$bug} = {%{$param{status}}};
+ } else {
+ my $location = getbuglocation($bug, 'summary');
+ next if not defined $location or not length $location;
+ my %status = %{ readbug( $bug, $location ) };
+ $status{id} = $bug;
+ $statuses{$bug} = \%status;
+ }
+ }