[Bps-public-commit] r11459 - in RT-Extension-Reports/html/Reports: Elements
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Apr 3 21:15:25 EDT 2008
Author: sunnavy
Date: Thu Apr 3 21:15:14 2008
New Revision: 11459
Added:
RT-Extension-Reports/html/Reports/Elements/SelectGroupBy
Modified:
RT-Extension-Reports/html/Reports/Elements/ShowResults
RT-Extension-Reports/html/Reports/Types/ActiveOrInactive
RT-Extension-Reports/html/Reports/Types/CreatedOrResolved
RT-Extension-Reports/html/Reports/Types/General
Log:
added groupby option for better output format
Added: RT-Extension-Reports/html/Reports/Elements/SelectGroupBy
==============================================================================
--- (empty file)
+++ RT-Extension-Reports/html/Reports/Elements/SelectGroupBy Thu Apr 3 21:15:14 2008
@@ -0,0 +1,61 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/copyleft/gpl.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+
+<input type="radio" name="<% $Name %>" value="date" <% $Default eq 'date'
+? 'checked="checked"' : () %> >Date</input>
+<input type="radio" name="<% $Name %>" value="queue" <% $Default eq 'queue'
+? 'checked="checked"' : () %>>Queue</input>
+
+<%INIT>
+
+</%INIT>
+
+<%ARGS>
+$Name => 'GroupBy'
+$Default => 'date'
+</%ARGS>
Modified: RT-Extension-Reports/html/Reports/Elements/ShowResults
==============================================================================
--- RT-Extension-Reports/html/Reports/Elements/ShowResults (original)
+++ RT-Extension-Reports/html/Reports/Elements/ShowResults Thu Apr 3 21:15:14 2008
@@ -63,7 +63,7 @@
</table>
<%INIT>
-my $seg;
+my $html;
if ( @$Results ) {
# we found something
@@ -86,26 +86,32 @@
$m->abort;
}
elsif ( $Type eq 'chart' ) {
+ my %sep;
+ require WebChart;
+
for ( @$Results ) {
- # join $day and $queue if possible
- splice @$_, 0, 2, $_->[1] ? ( join ':', @$_[0 .. 1] ) : $_->[0];
+ push @{$sep{$_->[0]}}, [@$_[ 1 .. @$_-1 ]];
}
- splice @$Headers, 0, 2, join ':', @$Headers[0,1];
- my @data;
+# splice @$Headers, 1, 1;
- for ( my $i = 0; $i < @$Results; $i++ ) {
- for ( my $j = 0; $j < @{$Results->[$i]}; $j++ ) {
- $data[$j][$i] = $Results->[$i][$j];
+ my $html = '';
+ for ( sort keys %sep ) {
+ my @data;
+
+ for ( my $i = 0; $i < @{$sep{$_}}; $i++ ) {
+ for ( my $j = 0; $j < @{$sep{$_}->[$i]}; $j++ ) {
+ $data[$j][$i] = $sep{$_}->[$i][$j];
+ }
}
- }
- require WebChart;
- my $wc = WebChart->new( width => 800, height => 600 );
- my ( $seg, $file ) = $wc->render( data => \@data, type => 'bars' );
- $r->content_type('image/png');
- open my $fh, '<', $file or die "can't open $file";
- local $/;
- $m->out( <$fh> );
+ use Cwd;
+ my $wc = WebChart->new( width => 800, height => 600, img_dir => getcwd . '/html/NoAuth/images/wc', web_img_dir => '/NoAuth/images/wc' );
+ my ( $seg, $file ) = $wc->render( data => \@data, type => 'bars',
+options => { legend_labels => [@$Headers[2 .. @$Headers -1]] } );
+ $html .= "<div>$_:</div><div>$seg</div>";
+ }
+ $m->out( $html );
+ $m->abort;
}
}
else {
Modified: RT-Extension-Reports/html/Reports/Types/ActiveOrInactive
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/ActiveOrInactive (original)
+++ RT-Extension-Reports/html/Reports/Types/ActiveOrInactive Thu Apr 3 21:15:14 2008
@@ -73,7 +73,15 @@
<td><&|/l&>Filter</&></td>
<td><& /Reports/Elements/EditFilter, Content => $Filter, Name => 'Filter' &></td>
</tr>
-<tr><td /><td>
+<tr>
+<td><&|/l&>GroupBy</&></td>
+<td>
+<& /Reports/Elements/SelectGroupBy, Name => 'GroupBy', Default => $GroupBy &>
+</td>
+</tr>
+<tr>
+<td><&|/l&>OutType</&></td>
+<td>
<& /Reports/Elements/SelectOutType, Name => 'OutType', Default => $OutType &>
</td>
</tr>
@@ -93,7 +101,13 @@
if ( $Run ) {
- @headers = ( 'Date', 'Queue', ucfirst $Type, '0-7', '8-14', '15-30', '31+' );
+ if ( $GroupBy eq 'date' ) {
+ @headers = ( 'Date', 'Queue', ucfirst $Type, '0-7', '8-14', '15-30', '31+' );
+ }
+ else {
+ @headers = ( 'Queue', 'Date', ucfirst $Type, '0-7', '8-14', '15-30', '31+' );
+
+ }
my ( $start_date, $end_date );
$start_date = RT::Date->new( $session{CurrentUser} );
@@ -173,19 +187,24 @@
}
for my $day ( sort keys %data ) {
- if ( keys %{$data{$day}} == 0 ) {
- push @results, [$day];
+ if ( $GroupBy eq 'date' ) {
+ for my $queue ( sort keys %{$data{$day}} ) {
+ push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ @headers[2 .. $#headers] ];
+ }
}
else {
for my $queue ( sort keys %{$data{$day}} ) {
- push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ push @results, [ $queue, $day, map { $data{$day}{$queue}{$_} }
@headers[2 .. $#headers] ];
}
+ @results = sort { $b->[0] cmp $a->[0] } @results;
}
+
}
$m->comp('/Reports/Elements/ShowResults', Headers => \@headers, Results
-=> \@results, Type => $OutType);
+=> \@results, Type => $OutType );
$m->abort;
}
@@ -207,5 +226,6 @@
$Filter => undef
$Type => 'active'
$OutType => 'screen'
+$GroupBy => 'date'
</%ARGS>
Modified: RT-Extension-Reports/html/Reports/Types/CreatedOrResolved
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/CreatedOrResolved (original)
+++ RT-Extension-Reports/html/Reports/Types/CreatedOrResolved Thu Apr 3 21:15:14 2008
@@ -74,7 +74,15 @@
<td><&|/l&>Filter</&></td>
<td><& /Reports/Elements/EditFilter, Content => $Filter, Name => 'Filter' &></td>
</tr>
-<tr><td /><td>
+<tr>
+<td><&|/l&>GroupBy</&></td>
+<td>
+<& /Reports/Elements/SelectGroupBy, Name => 'GroupBy', Default => $GroupBy &>
+</td>
+</tr>
+<tr>
+<td><&|/l&>OutType</&></td>
+<td>
<& /Reports/Elements/SelectOutType, Name => 'OutType', Default => $OutType &>
</td>
</tr>
@@ -94,7 +102,13 @@
if ( $Run ) {
- @headers = qw/Date Queue/;
+ if ( $GroupBy eq 'date' ) {
+ @headers = qw/Date Queue/;
+ }
+ else {
+ @headers = qw/Queue Date/;
+ }
+
if ( $Type eq 'created' ) {
push @headers, 'Created', 'Active', 'Inactive';
}
@@ -167,19 +181,24 @@
}
for my $day ( sort keys %data ) {
- if ( keys %{$data{$day}} == 0 ) {
- push @results, [$day];
+ if ( $GroupBy eq 'date' ) {
+ for my $queue ( sort keys %{$data{$day}} ) {
+ push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ @headers[2 .. $#headers] ];
+ }
}
else {
for my $queue ( sort keys %{$data{$day}} ) {
- push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ push @results, [ $queue, $day, map { $data{$day}{$queue}{$_} }
@headers[2 .. $#headers] ];
}
+ @results = sort { $b->[0] cmp $a->[0] } @results;
}
+
}
$m->comp('/Reports/Elements/ShowResults', Headers => \@headers, Results
-=> \@results, Type => $OutType);
+=> \@results, Type => $OutType );
$m->abort;
}
@@ -201,5 +220,6 @@
$Filter => undef
$Type => 'created'
$OutType => 'screen'
+$GroupBy => 'date'
</%ARGS>
Modified: RT-Extension-Reports/html/Reports/Types/General
==============================================================================
--- RT-Extension-Reports/html/Reports/Types/General (original)
+++ RT-Extension-Reports/html/Reports/Types/General Thu Apr 3 21:15:14 2008
@@ -65,7 +65,15 @@
<td><&|/l&>Filter</&></td>
<td><& /Reports/Elements/EditFilter, Content => $Filter, Name => 'Filter' &></td>
</tr>
-<tr><td /><td>
+<tr>
+<td><&|/l&>GroupBy</&></td>
+<td>
+<& /Reports/Elements/SelectGroupBy, Name => 'GroupBy', Default => $GroupBy &>
+</td>
+</tr>
+<tr>
+<td><&|/l&>OutType</&></td>
+<td>
<& /Reports/Elements/SelectOutType, Name => 'OutType', Default => $OutType &>
</td>
</tr>
@@ -143,17 +151,23 @@
}
for my $day ( sort keys %data ) {
- if ( keys %{$data{$day}} == 0 ) {
- push @results, [$day];
+ if ( $GroupBy eq 'date' ) {
+ for my $queue ( sort keys %{$data{$day}} ) {
+ push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ @headers[2 .. $#headers] ];
+ }
}
else {
for my $queue ( sort keys %{$data{$day}} ) {
- push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+ push @results, [ $queue, $day, map { $data{$day}{$queue}{$_} }
@headers[2 .. $#headers] ];
}
+ @results = sort { $b->[0] cmp $a->[0] } @results;
}
+
}
+
$m->comp('/Reports/Elements/ShowResults', Headers => \@headers, Results
=> \@results, Type => $OutType);
$m->abort;
@@ -175,5 +189,6 @@
$Run => undef
$Filter => undef
$OutType => 'screen'
+$GroupBy => 'date'
</%ARGS>
More information about the Bps-public-commit
mailing list