[Bps-public-commit] rt-extension-automaticassignment branch, master, updated. b9396c949aaae4eebe884bfcda373d27ee03a87e
Shawn Moore
shawn at bestpractical.com
Wed Aug 17 17:33:58 EDT 2016
The branch, master has been updated
via b9396c949aaae4eebe884bfcda373d27ee03a87e (commit)
from f5fdd3ad9c654388d6e5556b8850133fc77fa0d4 (commit)
Summary of changes:
.../Extension/AutomaticAssignment/Chooser/ActiveTickets.pm | 12 ++++--------
lib/RT/Extension/AutomaticAssignment/Chooser/RoundRobin.pm | 9 ++++++++-
2 files changed, 12 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit b9396c949aaae4eebe884bfcda373d27ee03a87e
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Aug 17 21:38:10 2016 +0000
Small bugfixes found through testing UI
diff --git a/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm b/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
index c33f1f3..83ed9cb 100644
--- a/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
+++ b/lib/RT/Extension/AutomaticAssignment/Chooser/ActiveTickets.pm
@@ -19,7 +19,7 @@ sub ChooseOwnerForTicket {
# each owner except for nobody
my %by_owner;
while (my $ticket = $tickets->Next) {
- next if $ticket->Owner = RT->Nobody->id;
+ next if $ticket->Owner == RT->Nobody->id;
$by_owner{ $ticket->Owner }++;
}
@@ -27,7 +27,7 @@ sub ChooseOwnerForTicket {
my @fewest;
for my $user (@users) {
- my $count = $by_owner{ $user->Id };
+ my $count = $by_owner{ $user->Id } || 0;
# either the first user we've seen, or this user
# has fewer tickets than anyone else we've seen this round
@@ -40,13 +40,9 @@ sub ChooseOwnerForTicket {
}
}
- # found exactly one user, so return this user as the owner
- if (@fewest == 1) {
- return $fewest[0];
- }
-
# all remaining users have the exact same number of active tickets, so
- # pick a random one
+ # pick a random one. if there is only one remaining, it will still pick
+ # that one
return $fewest[rand @fewest];
}
diff --git a/lib/RT/Extension/AutomaticAssignment/Chooser/RoundRobin.pm b/lib/RT/Extension/AutomaticAssignment/Chooser/RoundRobin.pm
index e242195..94264fe 100644
--- a/lib/RT/Extension/AutomaticAssignment/Chooser/RoundRobin.pm
+++ b/lib/RT/Extension/AutomaticAssignment/Chooser/RoundRobin.pm
@@ -13,10 +13,17 @@ sub ChooseOwnerForTicket {
my $queue = $ticket->Queue;
my $attr = 'AutomaticAssignment-RoundRobin-Queue' . $queue;
+ my %last_assignment;
+ for my $user (@users) {
+ my $attr = $user->FirstAttribute($attr);
+ $last_assignment{$user->Id} = $attr->Content if $attr;
+ $last_assignment{$user->Id} ||= 0;
+ }
+
# find the user whose last round-robin automatic assignment in this queue
# was the longest time ago
my $owner = reduce {
- ($a->FirstAttribute($attr)||0) < ($b->FirstAttribute($attr)||0) ? $a : $b
+ $last_assignment{$a->Id} < $last_assignment{$b->Id} ? $a : $b
} @users;
if ($owner) {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list