From 5421dfb6b2a144705ae97c34a42f780fa8e47b65 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 19 Dec 2020 17:15:18 +0100 Subject: [PATCH] Make the chore assignment type "Random" more random (closes #674) --- changelog/60_3.0.0_2020-12-22.md | 1 + services/ChoresService.php | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/changelog/60_3.0.0_2020-12-22.md b/changelog/60_3.0.0_2020-12-22.md index dcf6b96d..6d9a50c8 100644 --- a/changelog/60_3.0.0_2020-12-22.md +++ b/changelog/60_3.0.0_2020-12-22.md @@ -112,6 +112,7 @@ ### Chores improvements/fixes - Changed that not assigned chores on the chores overview page display now just a dash instead of an ellipsis in the "Assigned to" column to make this more clear (thanks @Germs2004) +- The assignment type "Random" now don't prevents anymore that the last user will be assigned next - Fixed (again) that weekly chores, where the next execution should be in the same week, were scheduled (not) always (but sometimes) for the next week only (thanks @shadow7412) - Fixed that the assignment type "In alphabetic order" did not work correctly (the last person in the list was always assigned next once reached) (thanks @fipwmaqzufheoxq92ebc) diff --git a/services/ChoresService.php b/services/ChoresService.php index e924210f..b3e6c881 100644 --- a/services/ChoresService.php +++ b/services/ChoresService.php @@ -40,7 +40,6 @@ class ChoresService extends BaseService } $nextExecutionUserId = null; - if ($chore->assignment_type == self::CHORE_ASSIGNMENT_TYPE_RANDOM) { // Random assignment and only 1 user in the group? Well, ok - will be hard to guess the next one... @@ -50,11 +49,7 @@ class ChoresService extends BaseService } else { - // Randomness in small groups will likely often result in the same user, so try it as long as this is the case - while ($nextExecutionUserId == null || $nextExecutionUserId == $lastDoneByUserId) - { - $nextExecutionUserId = $assignedUsers[array_rand($assignedUsers)]->id; - } + $nextExecutionUserId = $assignedUsers[array_rand($assignedUsers)]->id; } } elseif ($chore->assignment_type == self::CHORE_ASSIGNMENT_TYPE_IN_ALPHABETICAL_ORDER)