[Rt-commit] rt branch, 4.4/tweak-groups-in-ticket-roles, updated. rt-4.4.4-10-g2509f50a9
? sunnavy
sunnavy at bestpractical.com
Fri Mar 8 15:59:52 EST 2019
The branch, 4.4/tweak-groups-in-ticket-roles has been updated
via 2509f50a93cbbcc5ce060d9996e90459a51152e2 (commit)
from 987966888e536c38205a85b003a8ea5e9c969d75 (commit)
Summary of changes:
etc/upgrade/shrink-cgm-table.in | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit 2509f50a93cbbcc5ce060d9996e90459a51152e2
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Mar 9 04:56:22 2019 +0800
Update shrink-cgm-table to remove indirect members of ticket role groups
diff --git a/etc/upgrade/shrink-cgm-table.in b/etc/upgrade/shrink-cgm-table.in
index 8cd8ce2ae..ffe4fba4c 100644
--- a/etc/upgrade/shrink-cgm-table.in
+++ b/etc/upgrade/shrink-cgm-table.in
@@ -90,20 +90,37 @@ $cgms->Limit(
ENTRYAGGREGATOR => 'AND',
);
-my $total = $cgms->Count;
+my $cgms2 = RT::CachedGroupMembers->new( RT->SystemUser );
+$cgms2->Limit( FIELD => 'ImmediateParentId', VALUE => 'main.GroupId', OPERATOR => '!=', QUOTEVALUE => 0 );
+my $groups = $cgms2->Join(
+ ALIAS1 => 'main',
+ FIELD1 => 'GroupId',
+ TABLE2 => 'Groups',
+ FIELD2 => 'id'
+);
+$cgms2->Limit(
+ ALIAS => $groups,
+ FIELD => 'Domain',
+ VALUE => 'RT::Ticket-Role',
+ CASESENSITIVE => 0,
+);
+
+my $total = $cgms->Count + $cgms2->Count;
my $i = 0;
-FetchNext( $cgms, 'init' );
-while ( my $rec = FetchNext( $cgms ) ) {
- $i++;
- printf("\r%0.2f %%", 100 * $i / $total);
- $RT::Handle->BeginTransaction;
- my ($status) = $rec->Delete;
- unless ($status) {
- $RT::Logger->error( "Couldn't delete CGM #". $rec->id );
- exit 1;
+for my $cgms ( $cgms, $cgms2 ) {
+ FetchNext( $cgms, 'init' );
+ while ( my $rec = FetchNext($cgms) ) {
+ $i++;
+ printf( "\r%0.2f %%", 100 * $i / $total );
+ $RT::Handle->BeginTransaction;
+ my ($status) = $rec->Delete;
+ unless ($status) {
+ $RT::Logger->error( "Couldn't delete CGM #" . $rec->id );
+ exit 1;
+ }
+ $RT::Handle->Commit;
}
- $RT::Handle->Commit;
}
use constant PAGE_SIZE => 10000;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list