]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/CGI/Pkgreport.pm
use hash_slice instead of multi-line exists
[debbugs.git] / Debbugs / CGI / Pkgreport.pm
index e64300ad43cf8466ffd7614bae022ea79c98f020..01e661f30d987fff3cee189cab1803e6c1a4607d 100644 (file)
@@ -81,6 +81,9 @@ sub generate_package_info{
                                                    },
                                         bugs    => {type => ARRAYREF,
                                                    },
+                                        schema => {type => OBJECT,
+                                                   optional => 1,
+                                                  },
                                        },
                              );
 
@@ -91,19 +94,24 @@ sub generate_package_info{
 
      my %pkgsrc = %{getpkgsrc()};
      my $srcforpkg = $package;
-     if ($param{binary} and exists $pkgsrc{$package}
-        and defined $pkgsrc{$package}) {
-         $srcforpkg = $pkgsrc{$package};
+     if ($param{binary}) {
+        $srcforpkg =
+            binary_to_source(source_only => 1,
+                             scalar_only => 1,
+                             binary => $package,
+                             hash_slice(%param,qw(schema)),
+                            );
      }
 
      my $showpkg = html_escape($package);
-     my $maintainers = getmaintainers();
-     my $maint = $maintainers->{$srcforpkg};
-     if (defined $maint) {
+     my @maint = package_maintainer($param{binary}?'binary':'source',
+                                   $package
+                                  );
+     if (@maint) {
          print {$output} '<p>';
-         print {$output} (($maint =~ /,/)? "Maintainer for $showpkg is "
+         print {$output} (@maint > 1? "Maintainer for $showpkg is "
                           : "Maintainers for $showpkg are ") .
-                               package_links(maint => $maint);
+                               package_links(maintainer => \@maint);
          print {$output} ".</p>\n";
      }
      else {
@@ -131,20 +139,13 @@ sub generate_package_info{
          push @references, "to the <a href=\"$config{web_domain}/pseudo-packages$config{html_suffix}\">".
               "list of other pseudo-packages</a>";
      }
-     elsif (not defined $maint and not @{$param{bugs}}) {
-       # don't bother printing out this information, because it's
-       # already present above.
-       #  print {$output} "<p>There is no record of the " . html_escape($package) .
-       #       ($param{binary} ? " package" : " source package") .
-       #           ", and no bugs have been filed against it.</p>";
-     }
      else {
          if ($package and defined $config{package_pages} and length $config{package_pages}) {
               push @references, sprintf "to the <a href=\"%s\">%s package page</a>",
                    html_escape("$config{package_pages}/$package"), html_escape("$package");
          }
-         if (defined $config{subscription_domain} and
-             length $config{subscription_domain}) {
+         if (defined $config{package_tracking_domain} and
+             length $config{package_tracking_domain}) {
               my $ptslink = $param{binary} ? $srcforpkg : $package;
               # the pts only wants the source, and doesn't care about src: (#566089)
               $ptslink =~ s/^src://;
@@ -163,7 +164,7 @@ sub generate_package_info{
          $references[$#references] = "or $references[$#references]" if @references > 1;
          print {$output} "<p>You might like to refer ", join(", ", @references), ".</p>\n";
      }
-     if (defined $maint) {
+     if (@maint) {
          print {$output} "<p>If you find a bug not listed here, please\n";
          printf {$output} "<a href=\"%s\">report it</a>.</p>\n",
               html_escape("$config{web_domain}/Reporting$config{html_suffix}");
@@ -301,6 +302,9 @@ sub pkg_htmlizebugs {
                                          dist     => {type => SCALAR,
                                                       optional => 1,
                                                      },
+                                         schema   => {type => OBJECT,
+                                                      optional => 1,
+                                                     },
                                         }
                              );
      my @bugs = @{$param{bugs}};
@@ -350,27 +354,30 @@ sub pkg_htmlizebugs {
          push @{$exclude{$key}}, split /\s*,\s*/, $value;
      }
 
-     foreach my $bug (@bugs) {
-         my %status = %{get_bug_status(bug=>$bug,
-                                       (exists $param{dist}?(dist => $param{dist}):()),
-                                       bugusertags => $param{bugusertags},
-                                       (exists $param{version}?(version => $param{version}):()),
-                                       (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
-                                      )};
-         next unless %status;
-         next if bug_filter(bug => $bug,
-                            status => \%status,
-                            repeat_merged => $param{repeatmerged},
-                            seen_merged => \%seenmerged,
-                            (keys %include ? (include => \%include):()),
-                            (keys %exclude ? (exclude => \%exclude):()),
-                           );
-
-         my $html = "<li>"; #<a href=\"%s\">#%d: %s</a>\n<br>",
-         $html .= short_bug_status_html(status  => \%status,
-                                        options => $param{options},
-                                       ) . "\n";
-         push @status, [ $bug, \%status, $html ];
+     my $binary_to_source_cache = {};
+     my $statuses =
+        get_bug_statuses(bug => \@bugs,
+                         hash_slice(%param,
+                          qw(dist version schema bugusertags),
+                         ),
+                         (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
+                         binary_to_source_cache => $binary_to_source_cache,
+                        );
+     for my $bug (sort {$a <=> $b} keys %{$statuses}) {
+        next unless %{$statuses->{$bug}};
+        next if bug_filter(bug => $bug,
+                           status => $statuses->{$bug},
+                           repeat_merged => $param{repeatmerged},
+                           seen_merged => \%seenmerged,
+                           (keys %include ? (include => \%include):()),
+                           (keys %exclude ? (exclude => \%exclude):()),
+                          );
+
+        my $html = "<li>";     #<a href=\"%s\">#%d: %s</a>\n<br>",
+        $html .= short_bug_status_html(status  => $statuses->{$bug},
+                                       options => $param{options},
+                                      ) . "\n";
+        push @status, [ $bug, $statuses->{$bug}, $html ];
      }
      if ($param{bug_order} eq 'age') {
          # MWHAHAHAHA