Class: Report::ProjectMetric
- Inherits:
-
Object
- Object
- Report::ProjectMetric
- Defined in:
- app/models/report/project_metric.rb
Constant Summary collapse
- VALID_ENVIRONMENTS =
%w(Countertop Roof Outdoor Indoor Pipe).freeze
- VALID_ROOM_TYPES =
%w(addition basement bathroom bedroom breakfast-nook bridge carport countertop courtyard custom-mirror dining-room driveway enclosed-porch ensuite entry entry-hallway exit family-room four-season-room garage heated-balcony heated-bench home-theater-room kitchen landing laundry living-room master-bathroom master-bedroom mudroom office other patio pipe porch powder-room ramp recreation-media-room roof shop-floor shower-sauna stair sunroom three-season-room valet walkway)
Class Method Summary collapse
Class Method Details
.count_by_project_type(project_type) ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/report/project_metric.rb', line 25 def self.count_by_project_type(project_type) raise "Invalid project_type, must be one of #{VALID_ENVIRONMENTS.join(', ')}" unless project_type.in?(VALID_ENVIRONMENTS) Rails.cache.fetch([:project_metrics, :count_by_project_type, project_type], expires_in: 7.days) do Order.invoiced.joins(room_configurations: :room_type).where(RoomType[:environment].in(project_type)).count end end |
.count_by_room_type_seo_key(room_type) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/report/project_metric.rb', line 13 def self.count_by_room_type_seo_key(room_type) raise "Invalid room_type, must be one of #{VALID_ROOM_TYPES.join(', ')}" unless room_type.in?(VALID_ROOM_TYPES) Rails.cache.fetch([:project_metrics, :count_by_room_type_seo_key, room_type], expires_in: 7.days) do if room_type.include?('bedroom') room_type = %w(master-bedroom bedroom) elsif room_type.include?('bathroom') room_type = %w(master-bathroom bathroom) end Order.invoiced.joins(room_configurations: :room_type).where(RoomType[:seo_key].in(room_type)).count end end |