Prefer non-glitched over newer for canonical pet state on item page

Huh, this is a bit odd, I think we took this from Impress 2020's
`canonicalPetStateForBodyLoader` SQL query… but actually, it doesn't
really make sense? and `petStatesForPetTypeLoader` has a more sensible
ordering, and is the one the app uses in more ways. Maybe that's a
mistake we made back then, or a bug we fixed only in one place?

Anyway, this fixes why the item previews were like. using a LOT of
glitched pet states and I was like "dang did a lot of them break
recently?"

Nah we were just. not pulling the right ones lol
This commit is contained in:
Emi Matchu 2024-09-06 17:29:12 -07:00
parent 96215c037a
commit 052c02f841

View file

@ -124,8 +124,8 @@ class PetType < ApplicationRecord
pet_state.mood_id.present? ? -1 : 1, # Prefer mood is labeled pet_state.mood_id.present? ? -1 : 1, # Prefer mood is labeled
pet_state.mood_id, # Prefer mood is happy, then sad, then sick pet_state.mood_id, # Prefer mood is happy, then sad, then sick
gender == preferred_gender ? -1 : 1, # Prefer our "random" gender gender == preferred_gender ? -1 : 1, # Prefer our "random" gender
-pet_state.id, # Prefer newer pet states
!pet_state.glitched? ? -1 : 1, # Prefer is not glitched !pet_state.glitched? ? -1 : 1, # Prefer is not glitched
-pet_state.id, # Prefer newer pet states
] ]
}.first }.first
end end