[Bps-public-commit] rt-extension-automaticassignment branch, master, updated. b9910b08584eb5c0d2b29af9a1c2e960a0c98270

Shawn Moore shawn at bestpractical.com
Tue Sep 6 15:07:23 EDT 2016


The branch, master has been updated
       via  b9910b08584eb5c0d2b29af9a1c2e960a0c98270 (commit)
       via  fc463b93fc7459f930c406bceed5a3095e3fc6a5 (commit)
      from  4a780fbb240d81e4e1cbe2c3e5858a15452cdd92 (commit)

Summary of changes:
 lib/RT/Extension/AutomaticAssignment.pm            | 39 +++++++++++++++++++---
 .../AutomaticAssignment/Chooser/ActiveTickets.pm   | 10 ++++++
 2 files changed, 45 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit fc463b93fc7459f930c406bceed5a3095e3fc6a5
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 6 18:56:29 2016 +0000

    Add logging for which users are selected by each filter

diff --git a/lib/RT/Extension/AutomaticAssignment.pm b/lib/RT/Extension/AutomaticAssignment.pm
index a8c9884..539cbcc 100644
--- a/lib/RT/Extension/AutomaticAssignment.pm
+++ b/lib/RT/Extension/AutomaticAssignment.pm
@@ -22,6 +22,27 @@ sub _LoadedClass {
     return $class;
 }
 
+sub _LogFilteredUsers {
+    my $self   = shift;
+    my $ticket = shift;
+    my $users  = shift;
+    my $filter = shift;
+
+    my $description;
+    if (ref($filter)) {
+        my %config = %$filter;
+        my $name = delete $config{_name};
+        $description = "after filter $name\[" . (join ', ', map { "$_:$config{$_}" } keys %config) . "\]";
+    }
+    else {
+        $description = $filter;
+    }
+
+    my $count = @{ ref($users) eq 'ARRAY' ? $users : $users->ItemsArrayRef };
+    my $names = $count < 20 ? join ', ', map { $_->Name } @{ ref($users) eq 'ARRAY' ? $users : $users->ItemsArrayRef } : '(too many to list)';
+    RT->Logger->info("AutomaticAssignment for #" . $ticket->Id . ": $count users $description: $names");
+}
+
 sub _EligibleOwnersForTicket {
     my $self   = shift;
     my $ticket = shift;
@@ -34,10 +55,14 @@ sub _EligibleOwnersForTicket {
         VALUE    => [ RT->System->id, RT->Nobody->id ],
     );
 
+    $self->_LogFilteredUsers($ticket, $users, 'from initial collection');
+
     for my $filter (@{ $config->{filters} }) {
         my $class = $self->_LoadedClass('Filter', $filter->{_name});
-        $class->FilterOwnersForTicket($ticket, $users, $filter)
-            if !$class->FiltersUsersArray;
+        if (!$class->FiltersUsersArray) {
+            $class->FilterOwnersForTicket($ticket, $users, $filter);
+            $self->_LogFilteredUsers($ticket, $users, $filter);
+        }
     }
 
     return $users;
@@ -51,8 +76,10 @@ sub _FilterUsersArrayForTicket {
 
     for my $filter (@{ $config->{filters} }) {
         my $class = $self->_LoadedClass('Filter', $filter->{_name});
-        $users = $class->FilterOwnersForTicket($ticket, $users, $filter)
-            if $class->FiltersUsersArray;
+        if ($class->FiltersUsersArray) {
+            $users = $class->FilterOwnersForTicket($ticket, $users, $filter);
+            $self->_LogFilteredUsers($ticket, $users, $filter);
+        }
     }
 
     return $users;
@@ -115,8 +142,12 @@ sub OwnerForTicket {
 
     my @users = @{ $users->ItemsArrayRef };
 
+    $self->_LogFilteredUsers($ticket, \@users, 'after OwnTicket right check');
+
     @users = @{ $self->_FilterUsersArrayForTicket($ticket, \@users, $config) };
 
+    $self->_LogFilteredUsers($ticket, \@users, 'before Chooser');
+
     my $user = $self->_ChooseOwnerForTicket($ticket, \@users, $config);
 
     return $user;

commit b9910b08584eb5c0d2b29af9a1c2e960a0c98270
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Tue Sep 6 18:58:27 2016 +0000

    Logging for ActiveTickets chooser

diff --git a/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm b/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
index 83ed9cb..054b99c 100644
--- a/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
+++ b/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
@@ -40,6 +40,16 @@ sub ChooseOwnerForTicket {
         }
     }
 
+    if (@fewest > 1) {
+        RT->Logger->info("AutomaticAssignment for #" . $ticket->Id . ": selecting randomly from " . scalar(@fewest) . " users with " . ($fewest_ticket_count||0) . " active tickets: " . (join ', ', map { $_->Name } @fewest));
+    }
+    elsif (@fewest == 1) {
+        RT->Logger->info("AutomaticAssignment for #" . $ticket->Id . ": selecting single user " . $fewest[0]->Name . " with " . scalar(@fewest) . " active tickets");
+    }
+    elsif (@fewest == 0) {
+        RT->Logger->info("AutomaticAssignment for #" . $ticket->Id . ": no users with active tickets; bailing");
+    }
+
     # all remaining users have the exact same number of active tickets, so
     # pick a random one. if there is only one remaining, it will still pick
     # that one

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


More information about the Bps-public-commit mailing list