make label_at more concise
This commit is contained in:
parent
240f1b249f
commit
f452e1014a
1 changed files with 2 additions and 4 deletions
|
@ -18,10 +18,8 @@ class Zone < ApplicationRecord
|
|||
end
|
||||
|
||||
def label_at(date)
|
||||
labels_a = labels.pluck(:designated_on, :name)
|
||||
labels_a.find(-> { labels_a[-1] }) do |designated_on, _|
|
||||
date >= designated_on
|
||||
end.at(1)
|
||||
label = labels.where('designated_on < ?', date)&.first || labels.last
|
||||
label.name
|
||||
end
|
||||
|
||||
def available_at?(date)
|
||||
|
|
Loading…
Reference in a new issue