From 8ab5af1aca092d84c2e38f845b0fe2a02ba85798 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 31 Aug 2024 13:14:22 -0700 Subject: [PATCH] Remove unused logic for whether a zone is "sometimes" occupied I'm about to reimplement the more-robust version of what this used to be: how the item page used to say "sometimes" after certain zones in the occupied list. Now, we're going to do parity with 2020, and list the actual species! I like that this takes away the weird `#sometimes` method on the `Zone` class, which was always an odd hack for just this small thing. --- app/models/item.rb | 20 +++----------------- app/models/zone.rb | 8 -------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index 28660e96..5ef07b51 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -283,23 +283,9 @@ class Item < ApplicationRecord occupied_zones.map(&:id) end - def occupied_zones(options={}) - options[:scope] ||= Zone.all - all_body_ids = [] - zone_body_ids = {} - selected_assets = swf_assets.each do |swf_asset| - zone_body_ids[swf_asset.zone_id] ||= [] - body_ids = zone_body_ids[swf_asset.zone_id] - body_ids << swf_asset.body_id unless body_ids.include?(swf_asset.body_id) - all_body_ids << swf_asset.body_id unless all_body_ids.include?(swf_asset.body_id) - end - zones = options[:scope].find(zone_body_ids.keys) - zones_by_id = zones.inject({}) { |h, z| h[z.id] = z; h } - total_body_ids = all_body_ids.size - zone_body_ids.each do |zone_id, body_ids| - zones_by_id[zone_id].sometimes = true if body_ids.size < total_body_ids - end - zones + def occupied_zones + zone_ids = swf_assets.map(&:zone_id).uniq + Zone.find(zone_ids) end def affected_zones diff --git a/app/models/zone.rb b/app/models/zone.rb index 92e6ad93..e9cfd3cf 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -1,8 +1,4 @@ class Zone < ActiveRecord::Base - # When selecting zones that an asset occupies, we allow the zone to set - # whether or not the zone is "sometimes" occupied. This is false by default. - attr_writer :sometimes - scope :alphabetical, -> { order(:label) } scope :matching_label, ->(label) { where(plain_label: Zone.plainify_label(label)) @@ -13,10 +9,6 @@ class Zone < ActiveRecord::Base super({only: [:id, :depth, :label]}.merge(options)) end - def uncertain_label - @sometimes ? "#{label} sometimes" : label - end - def is_commonly_used_by_items # Zone metadata marks item zones with types 2, 3, and 4. But also, in # practice, the Biology Effects zone (type 1, ID 4) has been used for a few