From 5ade7e1a52a0a5ada28bb08928e37cc31eaf80f2 Mon Sep 17 00:00:00 2001 From: Italo Matos Date: Sat, 13 Dec 2025 16:31:48 -0300 Subject: [PATCH] Refactor: Simplify TimeWindowParser using Rails convenience methods - Replace `beginning_of_day..end_of_day` with `all_day` - Replace `beginning_of_week..end_of_week` with `all_week` - Replace `beginning_of_month..end_of_month` with `all_month` - Replace `beginning_of_year..end_of_year` with `all_year` These changes improve code readability by using idiomatic Rails methods that accomplish the same thing in a more concise and expressive way. --- app/models/time_window_parser.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/time_window_parser.rb b/app/models/time_window_parser.rb index a8da2a580..cdfc13c5f 100644 --- a/app/models/time_window_parser.rb +++ b/app/models/time_window_parser.rb @@ -31,21 +31,21 @@ class TimeWindowParser def parse(string) case normalize(string) when "today" - now.beginning_of_day..now.end_of_day + now.all_day when "yesterday" - (now - 1.day).beginning_of_day..(now - 1.day).end_of_day + (now - 1.day).all_day when "thisweek" - now.beginning_of_week..now.end_of_week + now.all_week when "thismonth" - now.beginning_of_month..now.end_of_month + now.all_month when "thisyear" - now.beginning_of_year..now.end_of_year + now.all_year when "lastweek" - (now - 1.week).beginning_of_week..(now - 1.week).end_of_week + (now - 1.week).all_week when "lastmonth" - (now - 1.month).beginning_of_month..(now - 1.month).end_of_month + (now - 1.month).all_month when "lastyear" - (now - 1.year).beginning_of_year..(now - 1.year).end_of_year + (now - 1.year).all_year end end