[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.1-250-g8ffdd00
Shawn Moore
shawn at bestpractical.com
Thu Jan 12 16:46:48 EST 2017
The branch, 4.4-trunk has been updated
via 8ffdd00b6eea3d7e20a05b040193240115878864 (commit)
via dcad34a6394d7ea7d54b9d316dfa8ff685b2b86e (commit)
from bb2413d07ae8556bf43c9789b2bb4c3c9095e673 (commit)
Summary of changes:
lib/RT/Report/Tickets.pm | 2 ++
t/charts/group-by-sla.t | 92 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
create mode 100644 t/charts/group-by-sla.t
- Log -----------------------------------------------------------------
commit dcad34a6394d7ea7d54b9d316dfa8ff685b2b86e
Author: Dave Goehrig <dave at bestpractical.com>
Date: Wed Jan 11 10:40:46 2017 -0500
Add ability to chart by SLA
Fixes: I#31824
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index cd74e1c..fdd8890 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -83,6 +83,8 @@ our @GROUPINGS = (
LastUpdated => 'Date', #loc_left_pair
CF => 'CustomField', #loc_left_pair
+
+ SLA => 'Enum', #loc_left_pair
);
our %GROUPINGS;
diff --git a/t/charts/group-by-sla.t b/t/charts/group-by-sla.t
new file mode 100644
index 0000000..3f18505
--- /dev/null
+++ b/t/charts/group-by-sla.t
@@ -0,0 +1,92 @@
+use strict;
+use warnings;
+
+use RT::Test
+ tests => undef,
+ config => <<THERE;
+Set(%ServiceAgreements, (
+ Default => '2',
+ Levels => {
+ '2' => {
+ StartImmediately => 1,
+ Response => { RealMinutes => 60 * 2 },
+ },
+ '4' => {
+ StartImmediately => 1,
+ Response => { RealMinutes => 60 * 4 },
+ },
+ },
+));
+THERE
+use RT::Ticket;
+
+my $q = RT::Test->load_or_create_queue( Name => 'test', SLADisabled => 0 );
+ok $q && $q->id, 'loaded or created queue';
+my $queue = $q->Name;
+
+my $t1 = RT::Ticket->new( $RT::SystemUser );
+my $t1_id = $t1->Create( Queue => $queue, Subject => 'test 1' );
+ok $t1_id, "created ticket #$t1_id";
+is $t1->SLA, '2', 'default sla';
+
+my $t2 = RT::Ticket->new( $RT::SystemUser );
+my $t2_id = $t2->Create( Queue => $queue, Subject => 'test 2' );
+ok $t2_id, "created ticket #$t2_id";
+is $t2->SLA, '2', 'default sla';
+$t2->SetSLA('4');
+is $t2->SLA, '4', 'new sla';
+
+my $t3 = RT::Ticket->new($RT::SystemUser);
+my $t3_id = $t3->Create( Queue => $queue, Subject => 'test 3' );
+ok $t3_id, "created ticket #$t3_id";
+is $t3->SLA, '2', 'default sla';
+
+use_ok 'RT::Report::Tickets';
+
+{
+ my $report = RT::Report::Tickets->new( RT->SystemUser );
+ my %columns = $report->SetupGroupings(
+ Query => 'Queue = '. $q->id,
+ GroupBy => ["SLA"],
+ Function => ['COUNT'],
+ );
+ $report->SortEntries;
+
+ my @colors = RT->Config->Get("ChartColors");
+ my $expected = {
+ 'thead' => [ {
+ 'cells' => [
+ { 'value' => 'SLA', 'type' => 'head' },
+ { 'rowspan' => 1, 'value' => 'Ticket count', 'type' => 'head', 'color' => $colors[0] },
+ ],
+ } ],
+ 'tfoot' => [ {
+ 'cells' => [
+ { 'colspan' => 1, 'value' => 'Total', 'type' => 'label' },
+ { 'value' => 3, 'type' => 'value' },
+ ],
+ 'even' => 1
+ } ],
+ 'tbody' => [
+ {
+ 'cells' => [
+ { 'value' => '2', 'type' => 'label' },
+ { 'query' => "(SLA = 2)", 'value' => '2', 'type' => 'value' },
+ ],
+ 'even' => 1
+ },
+ {
+ 'cells' => [
+ { 'value' => '4', 'type' => 'label' },
+ { 'query' => "(SLA = 4)", 'value' => '1', 'type' => 'value' },
+ ],
+ 'even' => 0
+ },
+ ]
+ };
+
+ my %table = $report->FormatTable( %columns );
+ is_deeply( \%table, $expected, "basic table" );
+}
+
+done_testing;
commit 8ffdd00b6eea3d7e20a05b040193240115878864
Merge: bb2413d dcad34a
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Thu Jan 12 21:45:35 2017 +0000
Merge branch '4.4/group-by-sla' into 4.4-trunk
-----------------------------------------------------------------------
More information about the rt-commit
mailing list