[rt-users] 2. try ;-) Limit user in a perl script

Björn Schulz bjoern.schulz at desy.de
Wed Sep 19 09:48:36 EDT 2012


Hi!

I try to ask again, because on my producton system it takes a very long
time to limit users (7 Minutes !!! per user :-(( ).

I try to search for users with no connections to any ticket and no
connection to any attachments to delete them later.

I can't use rt-shredder directly ;-)

I try this:

...
my $user  = RT::User->new($RT::SystemUser);
my $users = RT::Users->new($RT::SystemUser);
my $tix   = RT::Tickets->new($RT::SystemUser);


$users->FindAllRows ;

while (my $uid = $users->next ) {
 my $tickets   = RT::Tickets->new($RT::SystemUser);
 $user->Load($uid);
 $tickets->FromSQL('
    Type = "ticket" AND
    Watcher ="'.$user->EmailAddress.'"');

  Delete_User if ! $tickets->Count();
...



But it takes much time (about 7 minutes per user )
in my system for every user.

~500.000 tickets
~ 61.100 users

Is there a better method to limit the user with no tickets and no
attachments or what am I doing wrong?

Cheers,
  Björn



More information about the rt-users mailing list