From 9fe44e3f91784c4b2724c83f71ec96219207878c Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Wed, 13 Mar 2024 13:51:28 -0700 Subject: [PATCH] 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. --- app/controllers/outfits_controller.rb | 35 +++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index 1520017c..a4e3be17 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -49,24 +49,27 @@ class OutfitsController < ApplicationController def new @colors = Color.funny.alphabetical @species = Species.alphabetical - - newest_items = Item.newest. - select(:id, :name, :updated_at, :thumbnail_url, :rarity_index, :is_manually_nc) - .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_modeled_ratio = {} - @newest_unmodeled_items.each do |item| - h = item.predicted_missing_nonstandard_body_ids_by_species_by_color - standard_body_ids_by_species = item. - predicted_missing_standard_body_ids_by_species - if standard_body_ids_by_species.present? - h[:standard] = standard_body_ids_by_species + # HACK: Skip this in development, because it's slow! + unless Rails.env.development? + newest_items = Item.newest. + select(:id, :name, :updated_at, :thumbnail_url, :rarity_index, :is_manually_nc) + .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_modeled_ratio = {} + @newest_unmodeled_items.each do |item| + h = item.predicted_missing_nonstandard_body_ids_by_species_by_color + standard_body_ids_by_species = item. + predicted_missing_standard_body_ids_by_species + if standard_body_ids_by_species.present? + 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 - @newest_unmodeled_items_predicted_missing_species_by_color[item] = h - @newest_unmodeled_items_predicted_modeled_ratio[item] = item.predicted_modeled_ratio end @species_count = Species.count