[rt-users] Limit user in a perl script

Björn Schulz bjoern.schulz at desy.de
Thu Sep 13 10:27:34 EDT 2012


Hi!
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 takes much time (about 10s 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?

Cheers,
  Björn



More information about the rt-users mailing list