1
0
Fork 0
forked from OpenNeo/impress

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!
This commit is contained in:
Emi Matchu 2024-08-31 13:31:24 -07:00
parent e67830642c
commit 6312253b82

View file

@ -31,11 +31,12 @@ module ItemsHelper
end end
def standard_species_search_links 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) image = pet_type_image(pet_type, :happy, :zoom)
query = "species:#{pet_type.species.name}" query = "species:#{pet_type.species.name}"
link_to(image, items_path(:q => query)) link_to(image, items_path(:q => query))
end end.join.html_safe
end end
def closet_list_verb(owned) def closet_list_verb(owned)
@ -219,15 +220,6 @@ module ItemsHelper
private 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) def pet_type_image(pet_type, emotion, size)
src = pet_type_image_url(pet_type, emotion:, size:) src = pet_type_image_url(pet_type, emotion:, size:)
human_name = pet_type.species.name.humanize human_name = pet_type.species.name.humanize