);
my %bugs = ();
+ my $s = $param{schema};
my $keys = grep {$_ !~ $_non_search_key_regex} keys(%param);
die "Need at least 1 key to search by" unless $keys;
my $rs = $param{schema}->resultset('Bug');
[@aff_list],
'src_pkg.pkg' =>
[@aff_list],
+ 'me.unknown_affects' =>
+ [@aff_list]
},
},
{join => [{bug_affects_binpackages => 'bin_pkg'},
},
{join => {bug_binpackages => 'bin_pkg'}});
}
- if (exists $param{maintainer}) {
+ if (exists $param{maint}) {
my @maint_list =
map {$_ eq '' ? undef : $_}
- make_list($param{maintainer});
- $rs = $rs->search({-or => {correspondent => [@maint_list],
- correspondent2 => [@maint_list],
+ make_list($param{maint});
+ my $bin_pkgs_rs =
+ $s->resultset('BinPkg')->
+ search({'correspondent.addr' => [@maint_list]},
+ {join => {bin_vers =>
+ {src_ver =>
+ {maintainer => 'correspondent'}}},
+ columns => ['id'],
+ group_by => ['me.id'],
+ },
+ );
+ my $src_pkgs_rs =
+ $s->resultset('SrcPkg')->
+ search({'correspondent.addr' => [@maint_list]},
+ {join => {src_vers =>
+ {maintainer => 'correspondent'}},
+ columns => ['id'],
+ group_by => ['me.id'],
+ },
+ );
+ $rs = $rs->search({-or => {'bug_binpackages.bin_pkg' =>
+ { -in => $bin_pkgs_rs->get_column('id')->as_query},
+ 'bug_srcpackages.src_pkg' =>
+ { -in => $bin_pkgs_rs->get_column('id')->as_query},
},
},
- {join => {bug_affects_binpackage =>
- {bin_pkg =>
- {bin_ver =>
- {src_ver =>
- {maintainer => 'correspondent'}
- }}},
- {bug_affects_srcpackage =>
- {src_pkg =>
- {src_ver =>
- {maintainer => 'correspondent'}
- }}}}
- }
+ {join => ['bug_binpackages',
+ 'bug_srcpackages',
+ ]}
);
}
if (exists $param{src}) {
- $rs = $rs->search({-or => {map {('src_pkg.pkg' => $_)}
- make_list($param{src})},
+ # identify all of the srcpackages and binpackages that match first
+ my $src_pkgs_rs =
+ $s->resultset('SrcPkg')->
+ search({-or => [map {('me.pkg' => $_,
+ )}
+ make_list($param{src})],
+ columns => ['id'],
+ group_by => ['me.id'],
+ },
+ );
+ my $bin_pkgs_rs =
+ $s->resultset('BinPkg')->
+ search({-or => [map {('src_pkg.pkg' => $_,
+ )}
+ make_list($param{src})],
+ },
+ {join => {bin_vers => {src_ver => 'src_pkg'}},
+ columns => ['id'],
+ group_by => ['me.id'],
+ });
+ $rs = $rs->search({-or => {'bug_binpackages.bin_pkg' =>
+ { -in => $bin_pkgs_rs->get_column('id')->as_query},
+ 'bug_srcpackages.src_pkg' =>
+ { -in => $bin_pkgs_rs->get_column('id')->as_query},
+ 'me.unknown_package' =>
+ [make_list($param{src})],
+ },
},
- {join => {bug_srcpackages => 'src_pkg'}});
+ {join => ['bug_binpackages',
+ 'bug_srcpackages',
+ ]}
+ );
}
# tags are very odd, because we must handle usertags.
if (exists $param{tag}) {
return grep {$packages{$_} >= $package_keys} keys %packages;
}
-state %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";
}