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.:
# {
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.
# 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.