[Rt-commit] rt branch, 4.2/date-time-improvements-in-charts, updated. rt-3.8.10-123-gcfd08d8
Ruslan Zakirov
ruz at bestpractical.com
Sun Sep 11 10:01:54 EDT 2011
The branch, 4.2/date-time-improvements-in-charts has been updated
via cfd08d85d686cb0f3d2e4c5624b1d65408ee2b9f (commit)
from c99666c85d92e9cd4d8ec0f03739fce8fd96c61f (commit)
Summary of changes:
t/charts/compound-sql-function.t | 121 ++++++++++++++++++++++++++++++++++++++
1 files changed, 121 insertions(+), 0 deletions(-)
create mode 100644 t/charts/compound-sql-function.t
- Log -----------------------------------------------------------------
commit cfd08d85d686cb0f3d2e4c5624b1d65408ee2b9f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Sep 11 18:01:09 2011 +0400
test charting with compound SQL function
diff --git a/t/charts/compound-sql-function.t b/t/charts/compound-sql-function.t
new file mode 100644
index 0000000..b8dffce
--- /dev/null
+++ b/t/charts/compound-sql-function.t
@@ -0,0 +1,121 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use RT::Test tests => 14;
+use RT::Ticket;
+
+my $q1 = RT::Test->load_or_create_queue( Name => 'One' );
+ok $q1 && $q1->id, 'loaded or created queue';
+
+my $q2 = RT::Test->load_or_create_queue( Name => 'Two' );
+ok $q2 && $q2->id, 'loaded or created queue';
+
+my @tickets = add_tix_from_data(
+ { Queue => $q1->id, Resolved => 3*60 },
+ { Queue => $q1->id, Resolved => 3*60*60 },
+ { Queue => $q1->id, Resolved => 3*24*60*60 },
+ { Queue => $q1->id, Resolved => 3*30*24*60*60 },
+ { Queue => $q1->id, Resolved => 9*30*24*60*60 },
+ { Queue => $q2->id, Resolved => 7*60 },
+ { Queue => $q2->id, Resolved => 7*60*60 },
+ { Queue => $q2->id, Resolved => 7*24*60*60 },
+ { Queue => $q2->id, Resolved => 7*30*24*60*60 },
+ { Queue => $q2->id, Resolved => 24*30*24*60*60 },
+);
+
+use_ok 'RT::Report::Tickets';
+
+{
+ my $report = RT::Report::Tickets->new( RT->SystemUser );
+ my %columns = $report->SetupGroupings(
+ Query => 'id > 0',
+ GroupBy => ['Queue'],
+ Function => ['ALL(Created-Resolved)'],
+ );
+
+ my $expected = {
+ 'thead' => [
+ {
+ 'cells' => [
+ { 'rowspan' => 2, 'value' => 'Queue', 'type' => 'head' },
+ { 'colspan' => 4, 'value' => 'Created-Resolved', 'type' => 'head' }
+ ]
+ },
+ {
+ 'cells' => [
+ { 'value' => 'Minimum', 'type' => 'head' },
+ { 'value' => 'Average', 'type' => 'head' },
+ { 'value' => 'Maximum', 'type' => 'head' },
+ { 'value' => 'Summary', 'type' => 'head' }
+ ]
+ }
+ ],
+ 'tfoot' => [
+ {
+ 'cells' => [
+ { 'colspan' => 1, 'value' => 'Total', 'type' => 'label' },
+ { 'value' => '10 min', 'type' => 'value' },
+ { 'value' => '9 months', 'type' => 'value' },
+ { 'value' => '3 years', 'type' => 'value' },
+ { 'value' => '4 years', 'type' => 'value' }
+ ],
+ 'even' => 1
+ }
+ ],
+ 'tbody' => [
+ {
+ 'cells' => [
+ { 'value' => 'One', 'type' => 'label' },
+ { 'query' => '(Queue = 3)', 'value' => '3 min', 'type' => 'value' },
+ { 'query' => '(Queue = 3)', 'value' => '2 months', 'type' => 'value' },
+ { 'query' => '(Queue = 3)', 'value' => '9 months', 'type' => 'value' },
+ { 'query' => '(Queue = 3)', 'value' => '12 months', 'type' => 'value' }
+ ],
+ 'even' => 1
+ },
+ {
+ 'cells' => [
+ { 'value' => 'Two', 'type' => 'label' },
+ { 'query' => '(Queue = 4)', 'value' => '7 min', 'type' => 'value' },
+ { 'query' => '(Queue = 4)', 'value' => '6 months', 'type' => 'value' },
+ { 'query' => '(Queue = 4)', 'value' => '2 years', 'type' => 'value' },
+ { 'query' => '(Queue = 4)', 'value' => '3 years', 'type' => 'value' }
+ ],
+ 'even' => 0
+ }
+ ]
+ };
+
+
+ my %table = $report->FormatTable( %columns );
+ is_deeply( \%table, $expected, "basic table" );
+}
+
+
+sub add_tix_from_data {
+ my @data = @_;
+ my @res = ();
+
+ my $created = RT::Date->new( $RT::SystemUser );
+ $created->SetToNow;
+
+ my $resolved = RT::Date->new( $RT::SystemUser );
+
+ while (@data) {
+ $resolved->Set( Value => $created->Unix );
+ $resolved->AddSeconds( $data[0]{'Resolved'} );
+ my $t = RT::Ticket->new($RT::SystemUser);
+ my ( $id, undef $msg ) = $t->Create(
+ %{ shift(@data) },
+ Created => $created->ISO,
+ Resolved => $resolved->ISO,
+ );
+ ok( $id, "ticket created" ) or diag("error: $msg");
+ push @res, $t;
+ }
+ return @res;
+}
+
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list