Use minimum and maximum in enumerables
While the `minimum` and `maximum` methods have been available for a long time for ActiveRecord relations, Rails 7.0 has added these methods for enumerables as well. This means that the `start_date` and `end_date` methods in the ShiftsHelper can use `minimum` and `maximum` no matter whether they receive an ActiveRecord relation or an array of polls (I think the latter never happens, though, but I'm not 100% sure).
This commit is contained in:
@@ -24,12 +24,12 @@ module ShiftsHelper
|
||||
end
|
||||
|
||||
def start_date(polls)
|
||||
start_date = polls.map(&:starts_at).min.to_date
|
||||
start_date = polls.minimum(:starts_at).to_date
|
||||
[start_date, Date.current].max
|
||||
end
|
||||
|
||||
def end_date(polls)
|
||||
polls.map(&:ends_at).max.to_date
|
||||
polls.maximum(:ends_at).to_date
|
||||
end
|
||||
|
||||
def officer_select_options(officers)
|
||||
|
||||
Reference in New Issue
Block a user