[Rt-commit] r2797 - in rt/branches/QUEBEC-EXPERIMENTAL: . html/Search lib/RT/Report

jesse at bestpractical.com jesse at bestpractical.com
Thu Apr 21 01:38:19 EDT 2005


Author: jesse
Date: Thu Apr 21 01:38:19 2005
New Revision: 2797

Modified:
   rt/branches/QUEBEC-EXPERIMENTAL/   (props changed)
   rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart.png
   rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm
Log:
 r14011 at hualien:  jesse | 2005-04-21 01:37:27 -0400
 * Bugfixes, now charts by owner work


Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart.png
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart.png	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart.png	Thu Apr 21 01:38:19 2005
@@ -9,34 +9,54 @@
 use GD::Graph::bars;
 use RT::Report::Tickets;
 
-my $chart =GD::Graph::bars->new(600 => 400);
-my $tix = RT::Report::Tickets->new($session{'CurrentUser'});
+my $chart = GD::Graph::bars->new( 600 => 400 );
+my $tix   = RT::Report::Tickets->new( $session{'CurrentUser'} );
 
 my @groupby = (
-{ FIELD => $PrimaryGroupBy},
-#{ FIELD => $SecondaryGroupBy}
+    { FIELD => $PrimaryGroupBy },
+
+    #{ FIELD => $SecondaryGroupBy}
 );
-$tix->GroupByCols( @groupby);
+$tix->GroupByCols(@groupby);
 $tix->Column( FUNCTION => 'COUNT', FIELD => 'id' );
-$tix->Column( FIELD => $PrimaryGroupBy);
+$tix->Column( FIELD => $PrimaryGroupBy );
+
 #$tix->Column( FIELD => $SecondaryGroupBy);
 $tix->FromSQL($Query);
-while (my $entry = $tix->Next) {
-        my $q = RT::Queue->new($session{'CurrentUser'});
-       $q->Load($entry->__Value($PrimaryGroupBy)) ;
-    push @keys, $q->Name();
-    push @values, $entry->id;
-}
-
-         $chart->set(
-             x_label           => $PrimaryGroupBy,
-             y_label           => 'Tickets',
-             title             => "$Query\n split by $PrimaryGroupBy",
-         ) or die $chart->error;
-
-
-my $plot = $chart->plot([[@keys], [@values]]) or die $chart->error;
-$r->content_type('image/png');
-$m->out($plot->png);
-$m->abort();
+$tix->_DoSearch();
+warn YAML::Dump($tix);
+while ( my $entry = $tix->Next ) {
+    my $class;
+    if ( $PrimaryGroupBy eq 'Queue' ) {
+         $class = "RT::Queue";
+        }
+        elsif ( $PrimaryGroupBy eq 'Owner' ) {
+             $class = "RT::User";
+        }
+        if ($class) {
+            warn "Trying to load class $class";
+            warn  $entry->__Value($PrimaryGroupBy);
+            my $q = $class->new( $session{'CurrentUser'} );
+            $q->Load( $entry->__Value($PrimaryGroupBy) );
+            push @keys, $q->Name();
+        }
+        else {
+            push @keys, $entry->__Value($PrimaryGroupBy);
+        }
+        push @values, $entry->id;
+    }
+    use YAML;
+    warn YAML::Dump \@keys;
+
+    $chart->set(
+        x_label => $PrimaryGroupBy,
+        y_label => 'Tickets',
+        title   => "$Query\n split by $PrimaryGroupBy",
+      )
+      or die $chart->error;
+
+    my $plot = $chart->plot( [ [@keys], [@values] ] ) or die $chart->error;
+    $r->content_type('image/png');
+    $m->out( $plot->png );
+    $m->abort();
 </%init>

Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT/Report/Tickets.pm	Thu Apr 21 01:38:19 2005
@@ -3,6 +3,19 @@
 use RT::Report::Tickets::Entry;
 
 
+# Override the AddRecord from DBI::SearchBuilder::Unique. id isn't id here
+# wedon't want to disambiguate all the items with a count of 1.
+sub AddRecord {
+    my $self = shift;
+    my $record = shift;
+    push @{$self->{'items'}}, $record;
+    $self->{'rows'}++;
+}
+
+1;
+
+
+
 # Gotta skip over RT::Tickets->Next, since it does all sorts of crazy magic we 
 # don't want.
 sub Next {


More information about the Rt-commit mailing list