X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=9d397b825976f726c72ae270fd1e332ff8aebbd2;hp=331073e54164a7b232c12f439e06e636a13aceea;hb=0fe38bac72b8f278399b99d1521350fd5083a219;hpb=01c360c8831df87a69fe1f49a08dda22ded51950 diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index 331073e..9d397b8 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -33,6 +33,11 @@ use Exporter qw(import); use IO::Scalar; use Params::Validate qw(validate_with :types); +use Debbugs::Collection::Bug; + +use Carp; +use List::AllUtils qw(apply); + use Debbugs::Config qw(:config :globals); use Debbugs::CGI qw(:url :html :util); use Debbugs::Common qw(:misc :util :date); @@ -210,52 +215,14 @@ display below sub short_bug_status_html { my %param = validate_with(params => \@_, - spec => {status => {type => HASHREF, - }, - options => {type => HASHREF, - default => {}, - }, - bug_options => {type => HASHREF, - default => {}, - }, - snippet => {type => SCALAR, - default => '', - }, + spec => {bug => {type => OBJECT, + isa => 'Debbugs::Bug', + }, }, ); - my %status = %{$param{status}}; - - $status{tags_array} = [sort(split(/\s+/, $status{tags}))]; - $status{date_text} = strftime('%a, %e %b %Y %T UTC', gmtime($status{date})); - $status{mergedwith_array} = [split(/ /,$status{mergedwith})]; - - my @blockedby= split(/ /, $status{blockedby}); - $status{blockedby_array} = []; - if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) { - for my $b (@blockedby) { - my %s = %{get_bug_status($b)}; - next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); - push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - - my @blocks= split(/ /, $status{blocks}); - $status{blocks_array} = []; - if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) { - for my $b (@blocks) { - my %s = %{get_bug_status($b)}; - next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); - push @{$status{blocks_array}}, {bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - my $days = bug_archiveable(bug => $status{id}, - status => \%status, - days_until => 1, - ); - $status{archive_days} = $days; return fill_in_template(template => 'cgi/short_bug_status', - variables => {status => \%status, + variables => {bug => $param{bug}, isstrongseverity => \&Debbugs::Status::isstrongseverity, html_escape => \&Debbugs::CGI::html_escape, looks_like_number => \&Scalar::Util::looks_like_number, @@ -273,7 +240,7 @@ sub short_bug_status_html { sub pkg_htmlizebugs { my %param = validate_with(params => \@_, - spec => {bugs => {type => ARRAYREF, + spec => {bugs => {type => OBJECT, }, names => {type => ARRAYREF, }, @@ -316,23 +283,15 @@ sub pkg_htmlizebugs { }, } ); - my @bugs = @{$param{bugs}}; - - my @status = (); + my $bugs = $param{bugs}; my %count; my $header = ''; my $footer = "

Summary

\n"; - if (@bugs == 0) { + if ($bugs->count == 0) { return "

No reports found!

\n"; } - if ( $param{bug_rev} ) { - @bugs = sort {$b<=>$a} @bugs; - } - else { - @bugs = sort {$a<=>$b} @bugs; - } my %seenmerged; my %common = ( @@ -363,52 +322,50 @@ sub pkg_htmlizebugs { push @{$exclude{$key}}, split /\s*,\s*/, $value; } - 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, + my $sorter = sub {$_[0]->id <=> $_[1]->id}; + if ($param{bug_rev}) { + $sorter = sub {$_[1]->id <=> $_[0]->id} + } + elsif ($param{bug_order} eq 'age') { + $sorter = sub {$_[0]->modified->epoch <=> $_[1]->modified->epoch}; + } + elsif ($param{bug_order} eq 'agerev') { + $sorter = sub {$_[1]->modified->epoch <=> $_[0]->modified->epoch}; + } + my @status; + for my $bug ($bugs->sort($sorter)) { + next if + $bug->filter(repeat_merged => $param{repeatmerged}, + seen_merged => \%seenmerged, + (keys %include ? (include => \%include):()), + (keys %exclude ? (exclude => \%exclude):()), ); - 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 = "
  • "; ##%d: %s\n
    ", - $html .= short_bug_status_html(status => $statuses->{$bug}, - options => $param{options}, + $html .= short_bug_status_html(bug => $bug, ) . "\n"; - push @status, [ $bug, $statuses->{$bug}, $html ]; - } - if ($param{bug_order} eq 'age') { - # MWHAHAHAHA - @status = sort {$a->[1]{log_modified} <=> $b->[1]{log_modified}} @status; - } - elsif ($param{bug_order} eq 'agerev') { - @status = sort {$b->[1]{log_modified} <=> $a->[1]{log_modified}} @status; + push @status, [ $bug, $html ]; } + # parse bug order indexes into subroutines + my @order_subs = + map { + my $a = $_; + [map {parse_order_statement_to_subroutine($_)} @{$a}]; + } @{$param{prior}}; for my $entry (@status) { my $key = ""; - for my $i (0..$#{$param{prior}}) { - my $v = get_bug_order_index($param{prior}[$i], $entry->[1]); + for my $i (0..$#order_subs) { + my $v = get_bug_order_index($order_subs[$i], $entry->[0]); $count{"g_${i}_${v}"}++; $key .= "_$v"; } - $section{$key} .= $entry->[2]; + $section{$key} .= $entry->[1]; $count{"_$key"}++; } my $result = ""; if ($param{ordering} eq "raw") { - $result .= "\n"; + $result .= "\n"; } else { $header .= "
    \n