determine default zones according to tchap hs

This commit is contained in:
Christophe Robillard 2023-03-27 15:38:25 +02:00
parent d0ca05259a
commit 3705dc2553
3 changed files with 20 additions and 0 deletions

View file

@ -33,4 +33,9 @@ class Zone < ApplicationRecord
OpenStruct.new(id: zone.id, label: zone.label_at(date))
end
end
def self.default_for(tchap_hs)
sanitized_sql = ActiveRecord::Base.sanitize_sql "'#{tchap_hs}' = ANY (tchap_hs)"
Zone.where(sanitized_sql)
end
end