]> git.donarmstrong.com Git - debbugs.git/commitdiff
add cache_key support to binary_to_source when schema is set
authorDon Armstrong <don@donarmstrong.com>
Mon, 16 Apr 2018 21:56:58 +0000 (14:56 -0700)
committerDon Armstrong <don@donarmstrong.com>
Mon, 16 Apr 2018 21:56:58 +0000 (14:56 -0700)
Debbugs/Bugs.pm
Debbugs/Packages.pm

index 09e19a881fd6d5ce554c10d201932526bdd0dd31..5879f724b5564cbb4e99ad9a6a70c9e939f992c6 100644 (file)
@@ -560,6 +560,7 @@ sub get_bugs_by_db{
      }
      if (exists $param{affects}) {
         my @aff_list = make_list($param{affects});
+        s/^src:// foreach @aff_list;
          $rs = $rs->search({-or => {'bin_pkg.pkg' =>
                                    [@aff_list],
                                    'src_pkg.pkg' =>
@@ -608,7 +609,7 @@ sub get_bugs_by_db{
         $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},
+                                  { -in => $src_pkgs_rs->get_column('id')->as_query},
                                   },
                           },
                          {join => ['bug_binpackages',
@@ -623,7 +624,8 @@ sub get_bugs_by_db{
             search({-or => [map {('me.pkg' => $_,
                                  )}
                             make_list($param{src})],
-                    columns => ['id'],
+                   },
+                  { columns => ['id'],
                     group_by => ['me.id'],
                    },
                   );
@@ -639,8 +641,8 @@ sub get_bugs_by_db{
                   });
          $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},
+                                   'bug_srcpackages.src_pkg' =>
+                                  { -in => $src_pkgs_rs->get_column('id')->as_query},
                                    'me.unknown_packages' =>
                                    [make_list($param{src})],
                                   },
index 936bd76688b867ae9d9d3f6c660687d651746c80..783dc24e59a0ecc0cc450265a238e04f4bd9978f 100644 (file)
@@ -221,6 +221,15 @@ sub binary_to_source{
     my @archs = grep {defined $_} make_list(exists $param{arch}?$param{arch}:[]);
     return () unless @binaries;
 
+    my $cache_key = join("\1",
+                        join("\0",@binaries),
+                        join("\0",@versions),
+                        join("\0",@archs),
+                        join("\0",@param{qw(source_only scalar_only)}));
+    if (exists $param{cache}{$cache_key}) {
+       return $param{scalar_only} ? $param{cache}{$cache_key}[0]:
+           @{$param{cache}{$cache_key}};
+    }
     # any src:foo is source package foo with unspecified version
     @source = map {/^src:(.+)$/?
                       [$1,'']:()} @binaries;
@@ -245,10 +254,10 @@ sub binary_to_source{
            push @source,
                map {$_->{pkg}} $src_rs->all;
            if ($param{scalar_only}) {
-               return join(',',@source);
+               @source = join(',',@source);
            }
-           return @source;
-
+           $param{cache}{$cache_key} = \@source;
+           return $param{scalar_only}?$source[0]:@source;
        }
        my $src_rs = $param{schema}->resultset('SrcVer')->
            search_rs({'bin_pkg.pkg' => [@binaries],
@@ -281,16 +290,8 @@ sub binary_to_source{
                  $_->{src_vers}{ver},
                 ]} $src_rs->all;
        }
-       return @source;
-    }
-    my $cache_key = join("\1",
-                        join("\0",@binaries),
-                        join("\0",@versions),
-                        join("\0",@archs),
-                        join("\0",@param{qw(source_only scalar_only)}));
-    if (exists $param{cache}{$cache_key}) {
-       return $param{scalar_only} ? $param{cache}{$cache_key}[0]:
-           @{$param{cache}{$cache_key}};
+       $param{cache}{$cache_key} = \@source;
+       return $param{scalar_only}?$source[0]:@source;
     }
     for my $binary (@binaries) {
        _tie_binarytosource;