[Rt-commit] rt branch 5.0/chart-group-by-watchers-in-perl created. rt-5.0.3-216-g4161e49d2c
BPS Git Server
git at git.bestpractical.com
Fri Dec 16 15:36:57 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/chart-group-by-watchers-in-perl has been created
at 4161e49d2c92f006a467f246141fa68529541f88 (commit)
- Log -----------------------------------------------------------------
commit 4161e49d2c92f006a467f246141fa68529541f88
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Dec 16 22:58:37 2022 +0800
Test charts grouped by roles that contain groups
diff --git a/t/web/charting.t b/t/web/charting.t
index bb7ecb87b2..3169c428db 100644
--- a/t/web/charting.t
+++ b/t/web/charting.t
@@ -6,6 +6,8 @@ use RT::Test tests => undef, config => 'Set($EnableJSChart, 0);';
plan skip_all => 'GD required'
unless GD->require;
+my $core_group = RT::Test->load_or_create_group('core team');
+
for my $n (1..7) {
my $ticket = RT::Ticket->new( RT->SystemUser );
my $req = 'root' . ($n % 2) . '@localhost';
@@ -14,6 +16,9 @@ for my $n (1..7) {
Queue => "General",
Owner => "root",
Requestor => $req,
+ AdminCc => [ $req, $core_group->Id ],
+ Starts => '2022-12-10 00:00:00',
+ Started => '2022-12-11 00:00:00',
MIMEObj => MIME::Entity->build(
From => $req,
To => 'rt at localhost',
@@ -77,6 +82,31 @@ $m->warning_like( qr{'Requestor\.Phone' is not a valid grouping for reports} );
is( $m->content_type, "image/png" );
ok( length($m->content), "Has content" );
+# Group by AdminCc name
+$m->get_ok("/Search/Chart.html?Query=id>0&GroupBy=AdminCc.Name");
+$m->content_like( qr{<th[^>]*>AdminCc\s+Name</th>\s*<th[^>]*>Ticket count\s*</th>}, "Grouped by AdminCc" );
+$m->content_like( qr{Group: core team\s*</th>\s*<td[^>]*>\s*<a[^>]*>7</a>}, "Found group results in table" );
+$m->content_like( qr{root0\@localhost\s*</th>\s*<td[^>]*>\s*<a[^>]*>3</a>}, "Found results in table" );
+$m->content_like( qr{<img src="/Search/Chart\?}, "Found image" );
+
+$m->get_ok("/Search/Chart?Query=id>0&GroupBy=AdminCc.Name");
+is( $m->content_type, "image/png" );
+ok( length( $m->content ), "Has content" );
+
+# Group by AdminCc name and duration, which is calculated in perl instead of db.
+$m->get_ok("/Search/Chart.html?Query=id>0&GroupBy=AdminCc.Name&GroupBy=Starts+to+Started.Default");
+$m->content_like(
+ qr{<th[^>]*>AdminCc\s+Name</th>\s*<th[^>]*>Starts to Started Default\s*</th>\s*<th[^>]*>Ticket count\s*</th>},
+ "Grouped by AdminCc and Starts to Started" );
+$m->content_like( qr{Group: core team\s*</th>\s*<th[^>]*>24 hours</th>\s*<td[^>]*>\s*<a[^>]*>7</a>},
+ "Found group results in table" );
+$m->content_like( qr{root0\@localhost\s*</th>\s*<td[^>]*>\s*<a[^>]*>3</a>}, "Found results in table" );
+$m->content_like( qr{<img src="/Search/Chart\?}, "Found image" );
+
+$m->get_ok("/Search/Chart?Query=id>0&GroupBy=AdminCc.Name&GroupBy=Starts+to+Started.Default");
+is( $m->content_type, "image/png" );
+ok( length( $m->content ), "Has content" );
+
diag "Confirm subnav links use Query param before saved search in session.";
$m->get_ok( "/Search/Chart.html?Query=id>0" );
commit e6e7585a6d7fe7213b63fc98eaa38d04a6ea630e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Dec 16 22:30:29 2022 +0800
In case watcher value is "(no value)"
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index 0eac07e8f8..1fab2cc9d0 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -192,7 +192,8 @@ our %GROUPINGS_META = (
Display => sub {
my $self = shift;
my %args = (@_);
- if ( $args{FIELD} eq 'id' ) {
+ # VALUE could be "(no value)" from perl level calculation
+ if ( $args{FIELD} eq 'id' && ($args{'VALUE'} // '') !~ /\D/ ) {
my $princ = RT::Principal->new( $self->CurrentUser );
$princ->Load( $args{'VALUE'} ) if $args{'VALUE'};
return $self->loc('(no value)') unless $princ->Id;
commit 3dc86019d8d12594e4314989c32d48de8802542b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Dec 16 06:24:05 2022 +0800
Show direct members for charts grouped by watchers in perl calculation
Previously we showed all user members of the corresponding role groups,
instead of direct members which contain both users and groups.
This commit tweaks the logic in perl calculation to be consistent with
db calculation.
diff --git a/lib/RT/Report/Tickets.pm b/lib/RT/Report/Tickets.pm
index 407e034d03..0eac07e8f8 100644
--- a/lib/RT/Report/Tickets.pm
+++ b/lib/RT/Report/Tickets.pm
@@ -855,17 +855,16 @@ sub _DoSearch {
my @values;
if ( $ticket->can($group->{KEY}) ) {
my $method = $group->{KEY};
- push @values, @{$ticket->$method->UserMembersObj->ItemsArrayRef};
+ push @values, map { $_->MemberId } @{$ticket->$method->MembersObj->ItemsArrayRef};
}
elsif ( $group->{KEY} eq 'Watcher' ) {
- push @values, @{$ticket->$_->UserMembersObj->ItemsArrayRef} for /Requestor Cc AdminCc/;
+ push @values, map { $_->MemberId } @{$ticket->$_->MembersObj->ItemsArrayRef} for /Requestor Cc AdminCc/;
}
else {
RT->Logger->error("Unsupported group by $group->{KEY}");
next;
}
- @values = map { $_->_Value( $group->{SUBKEY} || 'Name' ) } @values;
@values = $self->loc('(no value)') unless @values;
$value = \@values;
}
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list