use warnings;
use strict;
+use feature 'state';
use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
use Exporter qw(import);
use Debbugs::Common qw(getparsedaddrs package_maintainer getmaintainers make_list hash_slice);
use Fcntl qw(O_RDONLY);
use MLDBM qw(DB_File Storable);
-use List::Util qw(first);
+use List::AllUtils qw(first);
use Carp;
=head2 get_bugs
=cut
-my $_non_search_key_regex = qr/^(bugs|archive|usertags|schema)$/;
+state $_non_search_key_regex = qr/^(bugs|archive|usertags|schema)$/;
my %_get_bugs_common_options =
(package => {type => SCALAR|ARRAYREF,
);
-my $_get_bugs_options = {%_get_bugs_common_options};
+state $_get_bugs_options = {%_get_bugs_common_options};
sub get_bugs{
my %param = validate_with(params => \@_,
spec => $_get_bugs_options,
=cut
-my $_get_bugs_by_idx_options =
+state $_get_bugs_by_idx_options =
{hash_slice(%_get_bugs_common_options,
(qw(package submitter severity tag archive),
qw(owner src maint bugs correspondent),
=cut
-my $_get_bugs_by_db_options =
+state $_get_bugs_by_db_options =
{hash_slice(%_get_bugs_common_options,
(qw(package submitter severity tag archive),
qw(owner src maint bugs correspondent),
$rs = $rs->search({-or => {map 'bin_package.'}})
}
if (exists $param{severity}) {
- $rs = $rs->search({-or => {map {('severity.severity' => $_)}
- make_list($param{severity})},
+ $rs = $rs->search({'severity.severity' =>
+ [make_list($param{severity})],
},
{join => 'severity'},
);
}
for my $key (qw(owner submitter done)) {
if (exists $param{$key}) {
- $rs = $rs->search({-or => {map {("${key}.addr" => $_)}
- make_list($param{$key})},
+ $rs = $rs->search({"${key}.addr" =>
+ [make_list($param{$key})],
},
{join => $key},
);
}
}
if (exists $param{correspondent}) {
- $rs = $rs->search({-or => {map {('message_correspondents.addr' => $_)}
- make_list($param{correspondent})},
+ $rs = $rs->search({'message_correspondents.addr' =>
+ [make_list($param{correspondent})],
},
{join => {correspondent =>
{bug_messages =>
);
}
if (exists $param{affects}) {
- $rs = $rs->search({-or => {map {('bin_pkg.pkg' => $_,
- 'src_pkg.pkg' => $_,
- )}
- make_list($param{affects}),
+ my @aff_list = make_list($param{affects});
+ $rs = $rs->search({-or => {'bin_pkg.pkg' =>
+ [@aff_list],
+ 'src_pkg.pkg' =>
+ [@aff_list],
},
},
{join => [{bug_affects_binpackages => 'bin_pkg'},
);
}
if (exists $param{package}) {
- $rs = $rs->search({-or => {map {('bin_pkg.pkg' => $_)}
- make_list($param{package})},
+ $rs = $rs->search({'bin_pkg.pkg' =>
+ [make_list($param{package})],
},
{join => {bug_binpackages => 'bin_pkg'}});
}
if (exists $param{maintainer}) {
- $rs = $rs->search({-or => {map {(correspondent => $_ eq '' ? undef : $_,
- correspondent2 => $_ eq '' ? undef : $_,
- )}
- make_list($param{maintainer})
- }
+ my @maint_list =
+ map {$_ eq '' ? undef : $_}
+ make_list($param{maintainer});
+ $rs = $rs->search({-or => {correspondent => [@maint_list],
+ correspondent2 => [@maint_list],
+ },
},
{join => {bug_affects_binpackage =>
{bin_pkg =>
=cut
-my $_get_bugs_flatfile_options =
+state $_get_bugs_flatfile_options =
{hash_slice(%_get_bugs_common_options,
map {$_ eq 'dist'?():($_)} keys %_get_bugs_common_options
)
return grep {$packages{$_} >= $package_keys} keys %packages;
}
-my %field_match = (
+state $field_match = {
'subject' => \&__contains_field_match,
'tags' => sub {
my ($field, $values, $status) = @_;
'originator' => \&__contains_field_match,
'forwarded' => \&__contains_field_match,
'owner' => \&__contains_field_match,
-);
+};
sub __bug_matches {
my ($hash, $status) = @_;
foreach my $key( keys( %$hash ) ) {
my $value = $hash->{$key};
- next unless exists $field_match{$key};
- my $sub = $field_match{$key};
+ next unless exists $field_match->{$key};
+ my $sub = $field_match->{$key};
if (not defined $sub) {
die "No defined subroutine for key: $key";
}