perf(zone): replace OpenStruct by a Struct label model

This commit is contained in:
Colin Darie 2024-01-16 19:02:07 +01:00
parent a0e64151d5
commit 4408f0f4fb
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
2 changed files with 2 additions and 1 deletions

View file

@ -0,0 +1 @@
LabelModel = Struct.new(:id, :label, keyword_init: true)

View file

@ -19,7 +19,7 @@ class Zone < ApplicationRecord
def self.available_at(date, without_zones = [])
(Zone.all - without_zones).filter { |zone| zone.available_at?(date) }.sort_by { |zone| zone.label_at(date) }
.map do |zone|
OpenStruct.new(id: zone.id, label: zone.label_at(date))
LabelModel.new(id: zone.id, label: zone.label_at(date))
end
end