Hack to speed up loading the homepage

The modeling code is slow! I think in production it's being cached, and
tbh I though I had development mode caching turned on over here, but
it's quite evidently _not_ doing it if so, so. Okay! Skip for now.
This commit is contained in:
Emi Matchu 2024-03-13 13:51:28 -07:00
parent 684dcb53ba
commit 9fe44e3f91

View file

@ -50,23 +50,26 @@ class OutfitsController < ApplicationController
@colors = Color.funny.alphabetical @colors = Color.funny.alphabetical
@species = Species.alphabetical @species = Species.alphabetical
newest_items = Item.newest. # HACK: Skip this in development, because it's slow!
select(:id, :name, :updated_at, :thumbnail_url, :rarity_index, :is_manually_nc) unless Rails.env.development?
.limit(18) newest_items = Item.newest.
@newest_modeled_items, @newest_unmodeled_items = select(:id, :name, :updated_at, :thumbnail_url, :rarity_index, :is_manually_nc)
newest_items.partition(&:predicted_fully_modeled?) .limit(18)
@newest_modeled_items, @newest_unmodeled_items =
newest_items.partition(&:predicted_fully_modeled?)
@newest_unmodeled_items_predicted_missing_species_by_color = {} @newest_unmodeled_items_predicted_missing_species_by_color = {}
@newest_unmodeled_items_predicted_modeled_ratio = {} @newest_unmodeled_items_predicted_modeled_ratio = {}
@newest_unmodeled_items.each do |item| @newest_unmodeled_items.each do |item|
h = item.predicted_missing_nonstandard_body_ids_by_species_by_color h = item.predicted_missing_nonstandard_body_ids_by_species_by_color
standard_body_ids_by_species = item. standard_body_ids_by_species = item.
predicted_missing_standard_body_ids_by_species predicted_missing_standard_body_ids_by_species
if standard_body_ids_by_species.present? if standard_body_ids_by_species.present?
h[:standard] = standard_body_ids_by_species h[:standard] = standard_body_ids_by_species
end
@newest_unmodeled_items_predicted_missing_species_by_color[item] = h
@newest_unmodeled_items_predicted_modeled_ratio[item] = item.predicted_modeled_ratio
end end
@newest_unmodeled_items_predicted_missing_species_by_color[item] = h
@newest_unmodeled_items_predicted_modeled_ratio[item] = item.predicted_modeled_ratio
end end
@species_count = Species.count @species_count = Species.count