Make the chore assignment type "Random" more random (closes #674)

This commit is contained in:
Bernd Bestel 2020-12-19 17:15:18 +01:00
parent 9d7ca55109
commit 5421dfb6b2
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 2 additions and 6 deletions

View File

@ -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)

View File

@ -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)