From 6312253b8299143770a1adb7ece888acc872ea2c Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 31 Aug 2024 13:31:24 -0700 Subject: [PATCH] Simplify standard_species_search_links helper The `build_on_pet_types` helper used to be reused on the items page, to generate the list of species to display. We don't use it anymore, so simplify and remove! --- app/helpers/items_helper.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index b28e1f46..01e2e446 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -31,11 +31,12 @@ module ItemsHelper end def standard_species_search_links - build_on_pet_types(Species.alphabetical) do |pet_type| + all_species = Species.alphabetical.map(&:id) + PetType.random_basic_per_species(all_species).map do |pet_type| image = pet_type_image(pet_type, :happy, :zoom) query = "species:#{pet_type.species.name}" link_to(image, items_path(:q => query)) - end + end.join.html_safe end def closet_list_verb(owned) @@ -219,15 +220,6 @@ module ItemsHelper private - def build_on_pet_types(species, special_color=nil, &block) - species_ids = species.map(&:id) - pet_types = special_color ? - PetType.where(:color_id => special_color.id, :species_id => species_ids). - order(:species_id) : - PetType.random_basic_per_species(species.map(&:id)) - pet_types.map(&block).join.html_safe - end - def pet_type_image(pet_type, emotion, size) src = pet_type_image_url(pet_type, emotion:, size:) human_name = pet_type.species.name.humanize