diff --git a/app/models/item.rb b/app/models/item.rb index 48d86834..3e5fa04f 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -294,7 +294,7 @@ class Item < ApplicationRecord # all bodies of the same color. (To my knowledge, anyway. I'm not aware # of any exceptions.) So, let's find those bodies by first finding those # colors. - basic_body_ids = PetType.basic.distinct.pluck(:body_id) + basic_body_ids = PetType.basic_body_ids basic_compatible_body_ids, nonbasic_compatible_body_ids = compatible_body_ids.partition { |bi| basic_body_ids.include?(bi) } @@ -335,9 +335,8 @@ class Item < ApplicationRecord end def predicted_missing_nonstandard_body_pet_types - PetType.joins(:color). - where(body_id: predicted_missing_body_ids - basic_body_ids, - colors: {standard: false}) + body_ids = predicted_missing_body_ids - PetType.basic_body_ids + PetType.joins(:color).where(body_id: body_ids, colors: {standard: false}) end def predicted_missing_nonstandard_body_ids_by_species_by_color diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index 0f96f5b6..37fb1eed 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -116,6 +116,10 @@ class PetType < ApplicationRecord "#{color.human_name}-#{species.human_name}" end + def self.basic_body_ids + PetType.basic.distinct.pluck(:body_id) + end + def self.all_by_ids_or_children(ids, pet_states) pet_states_by_pet_type_id = {} pet_states.each do |pet_state|