[Rt-commit] rt branch, 4.4/lazy-role-groups, repushed

? sunnavy sunnavy at bestpractical.com
Mon May 17 17:20:41 EDT 2021


The branch 4.4/lazy-role-groups was deleted and repushed:
       was 54b0e2a99c5aca4a404871852472531564f011dd
       now de27f385cb1a28a10c6ad9f709e6db592fbeeaae

1: d2061ce0e2 ! 1: d1c2ebfc17 Support to create ticket/asset role groups lazily
    @@ -2,11 +2,10 @@
     
         Support to create ticket/asset role groups lazily
         
    -    For objects with a large number of custom roles, creating
    -    all necessary role groups at object create time can add a
    -    large number of additional create operations in the DB,
    -    impacting performance. Creating them later when needed
    -    reduces time to create the object.
    +    For objects with a large number of custom roles, creating all necessary
    +    role groups at object create time can add a large number of additional
    +    create operations in the DB, impacting performance. Creating them later
    +    when needed reduces time to create the object.
         
         Since role groups may not exist, we need to use left join in searches.
     
    @@ -19,10 +18,7 @@
      
     +=item LazyRoleGroups
     +
    -+Boolean value that controls how role groups are created:
    -+
    -+1: create when necessary (lazy, default value)
    -+0: create immediately
    ++A boolean to control if to create role groups immediately or just when necessary
     +
      =back
      
    @@ -88,7 +84,15 @@
     +            GroupsAlias => $groups, New => 1,
              );
              if ($args{FIELD} eq "id") {
    -             # Save a left join to Users, if possible
    +             my @ids;
    +@@
    +             else {
    +                 my $cgm_2 = $self->NewAlias('CachedGroupMembers');
    +                 my $group_members_2 = $self->Join(
    ++                    TYPE   => 'LEFT',
    +                     ALIAS1 => $group_members,
    +                     FIELD1 => 'MemberId',
    +                     ALIAS2 => $cgm_2,
     
     diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
     --- a/lib/RT/Ticket.pm
    @@ -97,7 +101,7 @@
        Due -- an ISO date describing the ticket's due date and time in GMT
        MIMEObj -- a MIME::Entity object with the content of the initial ticket request.
        CustomField-<n> -- a scalar or array of values for the customfield with the id <n>
    -+  LazyRoleGroups -- boolean, create role groups immediately (0) or just when necessary (1, default)
    ++  LazyRoleGroups -- a boolean to control if to create role groups immediately or just when necessary
      
      Ticket links can be set up during create by passing the link type as a hask key and
      the ticket id to be linked to as a value (or a URI when linking to other objects).
2: 35b0c0208f = 2: 1568c9dd88 Default PrincipalId to 0 to avoid SQL error for not-existing role groups
-:  ------- > 3: 529e5dcbc6 Improve RoleGroup method to create the group if asked
-:  ------- > 4: 2f3b4f4ee7 Remove ticket Requestor/AdminCc/Cc validations as they are lazily created now
3: 54b0e2a99c ! 5: de27f385cb Update tests for the change of lazy role groups
    @@ -1,6 +1,32 @@
     Author: sunnavy <sunnavy at bestpractical.com>
     
    -    Update tests for the lazy role groups change
    +    Update tests for the change of lazy role groups
    +
    +diff --git a/t/api/group.t b/t/api/group.t
    +--- a/t/api/group.t
    ++++ b/t/api/group.t
    +@@
    + {
    +     RT::Test->load_or_create_queue( Name => 'General' );
    +     my $ticket    = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket role group' );
    +-    my $admincc   = $ticket->RoleGroup('AdminCc');
    ++    my $admincc   = $ticket->RoleGroup( 'AdminCc', Create => 1 );
    +     my $delegates = RT::Test->load_or_create_group('delegates');
    +     my $core      = RT::Test->load_or_create_group('core team');
    +     my $alice     = RT::Test->load_or_create_user( Name => 'alice' );
    +
    +diff --git a/t/api/rights.t b/t/api/rights.t
    +--- a/t/api/rights.t
    ++++ b/t/api/rights.t
    +@@
    + {
    +     RT::Test->load_or_create_queue( Name => 'General' );
    +     my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket role group' );
    +-    my $admincc = $ticket->RoleGroup('AdminCc');
    ++    my $admincc = $ticket->RoleGroup( 'AdminCc', Create => 1 );
    +     ok( $admincc->PrincipalObj->GrantRight( Right => 'ShowTicket', Object => $ticket->QueueObj ),
    +         'Grant AdminCc ShowTicket right' );
    + 
     
     diff --git a/t/api/ticket.t b/t/api/ticket.t
     --- a/t/api/ticket.t
    @@ -40,6 +66,28 @@
     +
      done_testing;
     
    +diff --git a/t/api/tickets.t b/t/api/tickets.t
    +--- a/t/api/tickets.t
    ++++ b/t/api/tickets.t
    +@@
    + diag "Ticket role group members";
    + {
    +     my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket role group' );
    +-    my $admincc = $ticket->RoleGroup('AdminCc');
    ++    my $admincc = $ticket->RoleGroup( 'AdminCc', Create => 1 );
    + 
    +     my $delegates = RT::Test->load_or_create_group('delegates');
    +     my $core      = RT::Test->load_or_create_group('core team');
    +@@
    + 
    +     my $abc = RT::Test->load_or_create_user( Name => 'abc' ); # so there are multiple users to search
    +     my $abc_ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket role group' );
    +-    ok( $abc_ticket->RoleGroup('AdminCc')->AddMember( $abc->PrincipalId ), 'Add abc to AdminCc' );
    ++    ok( $abc_ticket->RoleGroup( 'AdminCc', Create => 1 )->AddMember( $abc->PrincipalId ), 'Add abc to AdminCc' );
    + 
    +     my $tickets = RT::Tickets->new( RT->SystemUser );
    +     $tickets->FromSQL("Subject = 'test ticket role group' AND AdminCc.Name LIKE 'a'");
    +
     diff --git a/t/assets/roles.t b/t/assets/roles.t
     --- a/t/assets/roles.t
     +++ b/t/assets/roles.t
    @@ -52,6 +100,34 @@
      ok $asset && $asset->id, "Created asset";
      
      for my $object ($asset, $catalog, RT->System) {
    +
    +diff --git a/t/validator/group_members.t b/t/validator/group_members.t
    +--- a/t/validator/group_members.t
    ++++ b/t/validator/group_members.t
    +@@
    + diag "CGM recurisve check for ticket role groups";
    + {
    +     my $ticket    = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket role group' );
    +-    my $admincc   = $ticket->RoleGroup('AdminCc');
    ++    my $admincc   = $ticket->RoleGroup( 'AdminCc', Create => 1 );
    +     my $delegates = RT::Test->load_or_create_group('delegates');
    +     my $core      = RT::Test->load_or_create_group('core team');
    +     my $alice     = RT::Test->load_or_create_user( Name => 'alice' );
    +
    +diff --git a/t/validator/role_groups.t b/t/validator/role_groups.t
    +--- a/t/validator/role_groups.t
    ++++ b/t/validator/role_groups.t
    +@@
    + RT::Test->db_is_valid;
    + 
    + for my $object ( $ticket, $ticket->QueueObj ) {
    +-    for my $type (qw/Requestor AdminCc Cc Owner/) {
    ++    my @roles = 'Owner';
    ++    push @roles, qw/Requestor AdminCc Cc/ if $object->isa('RT::Queue');
    ++    for my $type (@roles) {
    +         ok( $object->RoleGroup($type)->id, "Recreated group $type for " . ref $object );
    +     }
    + }
     
     diff --git a/t/web/download_user_info.t b/t/web/download_user_info.t
     --- a/t/web/download_user_info.t



More information about the rt-commit mailing list