Cache the Item#appearances field

We call it enough times on this page, and it *does* have a SQL query,
that I want to cache it! (Also I want to make it fewer species queries
if I can tbh…)
This commit is contained in:
Emi Matchu 2024-09-05 17:41:04 -07:00
parent 0305817cec
commit 176ab20fd1

View file

@ -533,6 +533,10 @@ class Item < ApplicationRecord
end
def appearances
@appearances ||= build_appearances
end
def build_appearances
all_swf_assets = swf_assets.to_a
# If there are no assets yet, there are no appearances.