Fix Task.next_unassigned_tasks_for() for non-periodic tasks

This commit is contained in:
Patrick Gansterer 2017-10-29 00:06:05 +02:00
parent f209f4907e
commit f08715cda3

View file

@ -55,7 +55,7 @@ class Task < ActiveRecord::Base
def self.next_unassigned_tasks_for(user, max = 2) def self.next_unassigned_tasks_for(user, max = 2)
periodic_task_group_count = {} periodic_task_group_count = {}
self.unassigned_tasks_for(user).reject do |item| self.unassigned_tasks_for(user).reject do |item|
return false unless item.periodic_task_group next false unless item.periodic_task_group
count = periodic_task_group_count[item.periodic_task_group] || 0 count = periodic_task_group_count[item.periodic_task_group] || 0
periodic_task_group_count[item.periodic_task_group] = count + 1 periodic_task_group_count[item.periodic_task_group] = count + 1
count >= max count >= max