Merge branch 'main' into simpler-item-previews

This commit is contained in:
Emi Matchu 2024-08-31 13:31:46 -07:00
commit 2f341cfd39

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)
@ -223,15 +224,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