]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgreport.cgi
connect to and use the schema if it exists
[debbugs.git] / cgi / pkgreport.cgi
index eb7a61a2101600c9196bed3ca1f8eafaf8e73293..d27caa13dc39c58dd5dc0a7216d1086fd39c32a1 100755 (executable)
@@ -20,6 +20,7 @@ BEGIN{
 
 binmode(STDOUT,':encoding(UTF-8)');
 use POSIX qw(strftime nice);
+use List::AllUtils qw(uniq);
 
 use Debbugs::Config qw(:globals :text :config);
 
@@ -38,6 +39,14 @@ use Debbugs::CGI::Pkgreport qw(:all);
 
 use Debbugs::Text qw(:templates);
 
+use Debbugs::DB;
+
+my $s;
+if (defined $config{database}) {
+    $s = Debbugs::DB->connect($config{database}) or
+        die "Unable to connect to DB";
+}
+
 use CGI::Simple;
 my $q = new CGI::Simple;
 
@@ -228,7 +237,8 @@ our %cats = (
         "ord" => [2,3,4,1,0,5],
     } ],
     "oldview" => [ qw(status severity) ],
-    "normal" => [ qw(status severity classification) ],
+            "normal" => [ qw(status severity classification) ],
+            raw => [{nam => 'Raw',def => 'Raw'}],
 );
 
 if (exists $param{which} and exists $param{data}) {
@@ -275,7 +285,8 @@ if (defined $param{usertag}) {
      }
 }
 
-quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys;
+quitcgi("You have to choose something to select by", '400 Bad Request')
+  unless grep {exists $param{$_}} keys %package_search_keys;
 
 
 my $Archived = $param{archive} ? " Archived" : "";
@@ -376,6 +387,7 @@ my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
                  grep {$_ ne 'newest'}
                  keys %package_search_keys, 'archive'),
                 usertags => \%ut,
+                defined $s?(schema => $s):(),
                );
 
 # shove in bugs which affect this package if there is a package or a
@@ -389,6 +401,7 @@ if (not exists $param{affects} and not exists $param{noaffects} and
                          grep {$_ ne 'newest'}
                          keys %package_search_keys, 'archive'),
                         usertags => \%ut,
+                         defined $s?(schema => $s):(),
                        );
 }
 
@@ -433,9 +446,11 @@ my $result = pkg_htmlizebugs(bugs => \@bugs,
                             exclude => $exclude,
                             this => $this,
                             options => \%param,
+                             defined $s?(schema => $s):(),
                             (exists $param{dist})?(dist    => $param{dist}):(),
                            );
 
+print "Cache-Control: public, max-age=300\n";
 print "Content-Type: text/html; charset=utf-8\n\n";
 
 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
@@ -493,6 +508,9 @@ print fill_in_template(template=>'cgi/pkgreport_javascript');
 
 print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);
 
+$param{orderings} =
+    [uniq((grep {!$hidden{$_}} keys %cats),
+         $param{ordering})];
 print option_form(template => 'cgi/pkgreport_options',
                  param    => \%param,
                  form_options => $form_options,