From: Israel Madueme Date: Thu, 28 Mar 2019 14:06:08 +0000 (-0400) Subject: Bug 1539442 - Fix secbugs event builder to get more than the lastest event X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8600cc91382a90f17181c559b0181d8622f84fc1;p=thirdparty%2Fbugzilla.git Bug 1539442 - Fix secbugs event builder to get more than the lastest event --- diff --git a/Bugzilla/Report/SecurityRisk.pm b/Bugzilla/Report/SecurityRisk.pm index fa629adb9..f508390ad 100644 --- a/Bugzilla/Report/SecurityRisk.pm +++ b/Bugzilla/Report/SecurityRisk.pm @@ -29,15 +29,14 @@ use List::Util qw(any first sum uniq); use Mojo::File qw(tempfile); use POSIX qw(ceil); use Type::Utils; -use Types::Standard - qw(Num Int Bool Str HashRef ArrayRef CodeRef Maybe Map Dict Enum Optional Object); +use Types::Standard qw(:types); my $DateTime = class_type {class => 'DateTime'}; my $JSONBool = class_type {class => 'JSON::PP::Boolean'}; -has 'start_date' => (is => 'ro', required => 1, isa => $DateTime,); +has 'start_date' => (is => 'ro', required => 1, isa => $DateTime); -has 'end_date' => (is => 'ro', required => 1, isa => $DateTime,); +has 'end_date' => (is => 'ro', required => 1, isa => $DateTime); # The teams are loaded from an admin parameter containing JSON, e.g.: # { @@ -299,11 +298,20 @@ sub _build_events { AND bug_when >= '$start_date 00:00:00' GROUP BY bug_id , bug_when , field.name }; - my $result = Bugzilla->dbh->selectall_hashref($query, 'bug_id'); - my @events = values %$result; - foreach my $event (@events) { - $event->{bug_when} = datetime_from($event->{bug_when}); - } + # Don't use selectall_hashref as it only gets the latest event each bug. + my $result = Bugzilla->dbh->selectall_arrayref($query); + my $type = ArrayRef [Tuple [Int, Str, Str, Str, Str]]; + $type->assert_valid($result); + + my @events = map { + +{ + 'bug_id' => $_->[0], + 'bug_when' => datetime_from($_->[1]), + 'field_name' => $_->[2], + 'removed' => $_->[3], + 'added' => $_->[4], + } + } @$result; # We sort by reverse chronological order instead of ORDER BY # since values %hash doesn't guareentee any order. @@ -344,7 +352,7 @@ sub _build_results { # Undo sec keyword changes if ($event->{field_name} eq 'keywords') { - my $bug_sec_level = $bug->{sec_level}; + my $bug_sec_level = $bug->{sec_level} // ''; if ($event->{added} =~ /\b\Q$bug_sec_level\E\b/) { # If the currently set sec level was added in this event, remove it.