[Rt-commit] rt branch, 4.4/group-by-sla, created. rt-4.4.1-227-ga9cea10
Dave Goehrig
dave at bestpractical.com
Wed Jan 11 11:30:50 EST 2017
The branch, 4.4/group-by-sla has been created
at a9cea1059bce98d769e4f98ff8f667479517fe5e (commit)
- Log -----------------------------------------------------------------
commit a9cea1059bce98d769e4f98ff8f667479517fe5e
Author: Dave Goehrig <dave at bestpractical.com>
Date: Wed Jan 11 10:40:46 2017 -0500
Add group by SLA
added group by SLA dropdown option by adding to RT::Report::Tickets
added group-by-sla tests
NB: if you have a configured SLA option it can conflict with these
tests, while testing you should uncomment your etc/RT_SiteConfig.pm
SLA settings.
Fixes T#178216
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index cd74e1c..bc83fc2 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',
);
our %GROUPINGS;
diff --git a/t/charts/group-by-sla.t b/t/charts/group-by-sla.t
new file mode 100644
index 0000000..e8a0106
--- /dev/null
+++ b/t/charts/group-by-sla.t
@@ -0,0 +1,94 @@
+use strict;
+use warnings;
+
+BEGIN {
+ use RT::Ticket;
+ 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
+}
+
+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;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list