From 680fc3df8b18cab12b64c1bc4f66278b8c035c79 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Sun, 27 Dec 2020 17:15:15 +0200 Subject: [PATCH] #2534: Fix setting the due date in the calendar view. Reverts abad8c7 partly. --- app/controllers/todos_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 863086a0..54818b77 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -1121,18 +1121,19 @@ end end def count_old_due_empty(id) + due_today_date = Time.zone.now + due_this_week_date = Time.zone.now.end_of_week + due_next_week_date = due_this_week_date + 7.days + due_this_month_date = Time.zone.now.end_of_month + case id when "due_today" - due_today_date = Time.zone.now return current_user.todos.not_completed.where('todos.due <= ?', due_today_date).count when "due_this_week" - due_this_week_date = Time.zone.now.end_of_week return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_today_date, due_this_week_date).count when "due_next_week" - due_next_week_date = due_this_week_date + 7.days return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_this_week_date, due_next_week_date).count when "due_this_month" - due_this_month_date = Time.zone.now.end_of_month return current_user.todos.not_completed.where('todos.due > ? AND todos.due <= ?', due_next_week_date, due_this_month_date).count when "due_after_this_month" return current_user.todos.not_completed.where('todos.due > ?', due_this_month_date).count