[Bps-public-commit] r10986 - RT-Extension-Reports/html/Reports/Types

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Mar 4 04:23:33 EST 2008


Author: sunnavy
Date: Tue Mar  4 04:23:33 2008
New Revision: 10986

Added:
   RT-Extension-Reports/html/Reports/Types/CreatedOrResolved
      - copied, changed from r10979, /RT-Extension-Reports/html/Reports/Types/Created
Removed:
   RT-Extension-Reports/html/Reports/Types/Created

Log:
mv Created to CreatedOrResolved

Copied: RT-Extension-Reports/html/Reports/Types/CreatedOrResolved (from r10979, /RT-Extension-Reports/html/Reports/Types/Created)
==============================================================================
--- /RT-Extension-Reports/html/Reports/Types/Created	(original)
+++ RT-Extension-Reports/html/Reports/Types/CreatedOrResolved	Tue Mar  4 04:23:33 2008
@@ -52,10 +52,12 @@
 <form>
 <table align="center">
 <tr>
-<td />
+<td><&|/l&>Type</&></td>
 <td>
-<input type="radio" name="Type" value="simple">Simple</input>
-<input type="radio" name="Type" value="verbose">Verbose</input>
+<input type="radio" name="Type" value="created" <% $Type eq 'created' ?
+'checked="checked"' : ()%> >Created</input>
+<input type="radio" name="Type" value="resolved" <% $Type eq 'resolved' ?
+'checked="checked"' : ()%>>Resolved</input>
 </td>
 </tr>
 <tr>
@@ -91,9 +93,12 @@
 
 
 if ( $Run ) {
-    @headers = qw/Date Queue Created/;
-    if ( $Type eq 'verbose' ) {
-        push @headers, 'Open', 'Resolved';
+    @headers = qw/Date Queue/;
+    if ( $Type eq 'created' ) {
+        push @headers, 'Created', 'Active', 'Inactive';
+    }
+    else {
+        push @headers, 'Resolved', '0-7', '8-14', '15-30', '31+';
     }
 
     my ( $start_date, $end_date );
@@ -106,16 +111,7 @@
     $end_date->AddDay; # we want the date ranage to be inclusive
     my $tickets = RT::Tickets->new( $session{CurrentUser} );
 
-    $tickets->FromSQL( q{ Created >= '} . $start_date->ISO . q{ ' AND
-Created < '} . $end_date->ISO . q{'} );
-
-    my $tmp_date = RT::Date->new( $session{CurrentUser} );
-    $tmp_date->Set( Value => $start_date->Unix );
-    while ( $tmp_date->Unix < $end_date->Unix ) {
-        $data{$tmp_date->Date} = {};
-        $tmp_date->AddDay;
-    }
-
+    $tickets->UnLimit;
 
     TICKET:
     while ( my $ticket = $tickets->Next ) {
@@ -131,26 +127,52 @@
                     => $ticket, Value => $value, Operator => $op, Field =>
                     $field );
         }
-        $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[0]++; # Created
-        if ( $Type eq 'verbose' ) {
+
+        if ( $Type eq 'created' && $ticket->CreatedObj->Unix >=
+$start_date->Unix && $ticket->CreatedObj->Unix < $end_date->Unix ) {
+            $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}{Created}++; # Created
             if ( $ticket->QueueObj->IsActiveStatus( $ticket->Status ) ) {
-                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[1]++;
+                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}{Active}++;
 # Active
             }
             else {
-                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}[2]++;
+                $data{$ticket->CreatedObj->Date}{$ticket->QueueObj->Name}{Inactive}++;
 # Inactive
             }
         }
+        elsif ( $Type eq 'resolved' && $ticket->ResolvedObj->Unix >=
+$start_date->Unix && $ticket->ResolvedObj->Unix < $end_date->Unix ) {
+                my $res = $ticket->ResolvedObj->Date;
+
+                $data{$res}{$ticket->QueueObj->Name}{Resolved}++;
+                my $age;
+                $age = int( ($ticket->ResolvedObj->Unix - $ticket->CreatedObj->Unix)/3600/24) + 1;
+
+                $age = 1 if $age < 1; # make it 1 day if less than 1 day
+
+                if ( $age <= 7 ) {
+                    $data{$res}{$ticket->QueueObj->Name}{'0-7'}++;
+                }
+                elsif ( $age <= 14 ) {
+                    $data{$res}{$ticket->QueueObj->Name}{'8-14'}++;
+                }
+                elsif ( $age <= 30 ) {
+                    $data{$res}{$ticket->QueueObj->Name}{'15-30'}++;
+                }
+                else {
+                    $data{res}{$ticket->QueueObj->Name}{'31+'}++;
+                }
+            }
     }
 
-    for ( sort keys %data ) {
-        if ( keys %{$data{$_}} == 0 ) {
-            push @results, [$_];
+    for my $day ( sort keys %data ) {
+        if ( keys %{$data{$day}} == 0 ) {
+            push @results, [$day];
         }
         else {
-            for my $queue ( sort keys %{$data{$_}} ) {
-                push @results, [ $_, $queue, @{$data{$_}{$queue}} ];
+            for my $queue ( sort keys %{$data{$day}} ) {
+                push @results, [ $day, $queue, map { $data{$day}{$queue}{$_} }
+                @headers[2 .. $#headers] ]; 
             }
         }
     }
@@ -185,6 +207,6 @@
 $EndDate => undef
 $Run => undef
 $Filter => undef
-$Type => 'simple'
+$Type => 'created'
 </%ARGS>
 



More information about the Bps-public-commit mailing list