Preload SWF asset manifests during wardrobe item search
This doesn't matter a ton in production, where we already have most of our manifests loaded! But it matters a lot on my relatively-fresh development instance, at times like now when images.neopets.com is slow to respond. A single item search was taking minutes before this change (5 seconds of timeout per asset for 30 items!), but now takes a few seconds the first time, as it should!
This commit is contained in:
parent
d3d3297a28
commit
3eb40b2a4f
1 changed files with 7 additions and 1 deletions
|
@ -171,7 +171,13 @@ class ItemsController < ApplicationController
|
|||
appearance_params[:color_id], appearance_params[:species_id])
|
||||
end
|
||||
|
||||
target.appearances_for(@items.map(&:id), swf_asset_includes: [:zone])
|
||||
target.appearances_for(@items.map(&:id), swf_asset_includes: [:zone]).
|
||||
tap do |appearances|
|
||||
# Preload the manifests for these SWF assets concurrently, rather than
|
||||
# loading them in sequence when we generate the JSON.
|
||||
swf_assets = appearances.values.map(&:swf_assets).flatten
|
||||
SwfAsset.preload_manifests(swf_assets)
|
||||
end
|
||||
end
|
||||
|
||||
def search_error(e)
|
||||
|
|
Loading…
Reference in a new issue