Show only 2 tasks of the same periodic_task_group at dashboard
This commit is contained in:
parent
ad96159336
commit
47e4a9afdf
2 changed files with 13 additions and 3 deletions
|
@ -8,7 +8,7 @@ class HomeController < ApplicationController
|
||||||
@next_tasks = Task.order(:due_date).next_assigned_tasks_for(current_user)
|
@next_tasks = Task.order(:due_date).next_assigned_tasks_for(current_user)
|
||||||
# count tasks with no responsible person
|
# count tasks with no responsible person
|
||||||
# tasks for groups the current user is not a member are ignored
|
# tasks for groups the current user is not a member are ignored
|
||||||
@unassigned_tasks = Task.order(:due_date).unassigned_tasks_for(current_user)
|
@unassigned_tasks = Task.order(:due_date).next_unassigned_tasks_for(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile
|
def profile
|
||||||
|
|
|
@ -52,6 +52,16 @@ class Task < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.next_unassigned_tasks_for(user, max = 2)
|
||||||
|
periodic_task_group_count = {}
|
||||||
|
self.unassigned_tasks_for(user).reject do |item|
|
||||||
|
return false unless item.periodic_task_group
|
||||||
|
count = periodic_task_group_count[item.periodic_task_group] || 0
|
||||||
|
periodic_task_group_count[item.periodic_task_group] = count + 1
|
||||||
|
count >= max
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def periodic?
|
def periodic?
|
||||||
not periodic_task_group.nil?
|
not periodic_task_group.nil?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue