[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.4-502-gea3094cef7

Jim Brandt jbrandt at bestpractical.com
Fri May 28 17:04:02 EDT 2021


The branch, 4.4-trunk has been updated
       via  ea3094cef7ec7639802bbad9f1da9eb1aff54da0 (commit)
       via  2b197e8d42c7b45ec470c88b5dc8db15493472e2 (commit)
      from  6a0c9a23f7216104249cb32492cfe8d0d4a087de (commit)

Summary of changes:
 lib/RT/SearchBuilder/Role/Roles.pm | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 2b197e8d42c7b45ec470c88b5dc8db15493472e2
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jun 4 03:04:00 2019 +0800

    Exclude user defined groups in role groups for _WatcherJoin
    
    _WatcherJoin is actaully for Users. As user defined groups are also
    supported in role groups, we need to exclude them here.  This commit
    fixes the wrong NULLs in Users table when user defined groups are in
    role groups. Without this, ticket search charts grouped by role groups
    will get wrong "(no value)" counts.

diff --git a/lib/RT/SearchBuilder/Role/Roles.pm b/lib/RT/SearchBuilder/Role/Roles.pm
index 5980882d31..f7ea0fb24a 100644
--- a/lib/RT/SearchBuilder/Role/Roles.pm
+++ b/lib/RT/SearchBuilder/Role/Roles.pm
@@ -189,11 +189,10 @@ sub _WatcherJoin {
     my $group_members = $self->_GroupMembersJoin( GroupsAlias => $groups );
     # XXX: work around, we must hide groups that
     # are members of the role group we search in,
-    # otherwise them result in wrong NULLs in Users
-    # table and break ordering. Now, we know that
-    # RT doesn't allow to add groups as members of the
-    # ticket roles, so we just hide entries in CGM table
-    # with MemberId == GroupId from results
+    # otherwise they result in wrong NULLs in Users
+    # table and break ordering.
+
+    # Exclude role groups themselves
     $self->Limit(
         LEFTJOIN   => $group_members,
         FIELD      => 'GroupId',
@@ -201,6 +200,26 @@ sub _WatcherJoin {
         VALUE      => "$group_members.MemberId",
         QUOTEVALUE => 0,
     );
+
+    # Exclude groups added in role groups.  It technially also covers
+    # the above limit, but with that limit, SQL could be faster as it
+    # reduces rows to process before the following join.
+
+    my $groups_2 = $self->Join(
+        TYPE   => 'LEFT',
+        ALIAS1 => $group_members,
+        FIELD1 => 'MemberId',
+        TABLE2 => 'Groups',
+        FIELD2 => 'id',
+    );
+    $self->Limit(
+        ALIAS           => $groups_2,
+        FIELD           => 'id',
+        OPERATOR        => 'IS',
+        VALUE           => 'NULL',
+        SUBCLAUSE       => "exclude_groups",
+    );
+
     my $users = $self->Join(
         TYPE            => 'LEFT',
         ALIAS1          => $group_members,

commit ea3094cef7ec7639802bbad9f1da9eb1aff54da0
Merge: 6a0c9a23f7 2b197e8d42
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri May 28 16:50:07 2021 -0400

    Merge branch '4.4/exclude-groups-in-watcher-join' into 4.4-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list