From ffa73b6b037c64e0bb2755fb4f9b7a06f9d5e964 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 11:38:10 -0700 Subject: [PATCH] Simplify item page rendering Just removing some caching and the expiration of it! There's still more superfluous(?) caching on the item page to audit, but these seem a bit more sensible about avoiding loading extra data. --- app/controllers/items_controller.rb | 14 +++---- app/models/item/update_task.rb | 2 - app/views/items/show.html.haml | 59 ++++++++++++++--------------- 3 files changed, 34 insertions(+), 41 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index e44e3065..ee8edc94 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -61,14 +61,12 @@ class ItemsController < ApplicationController respond_to do |format| format.html do - unless localized_fragment_exist?("items/#{@item.id} info") - @occupied_zones = @item.occupied_zones( - scope: Zone.includes_translations.alphabetical - ) - @restricted_zones = @item.restricted_zones( - scope: Zone.includes_translations.alphabetical - ) - end + @occupied_zones = @item.occupied_zones( + scope: Zone.includes_translations.alphabetical + ) + @restricted_zones = @item.restricted_zones( + scope: Zone.includes_translations.alphabetical + ) unless localized_fragment_exist?("items/#{@item.id} contributors") @contributors_with_counts = @item.contributors_with_counts diff --git a/app/models/item/update_task.rb b/app/models/item/update_task.rb index e53f869d..ce986760 100644 --- a/app/models/item/update_task.rb +++ b/app/models/item/update_task.rb @@ -16,8 +16,6 @@ class Item private def self.expire_cache_for(item) - expire_fragment_in_all_locales("items/#{item.id} header") - expire_fragment_in_all_locales("items/#{item.id} info") expire_key_in_all_locales("items/#{item.id}#as_json") end end diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 0bade545..490bbd3c 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -1,20 +1,19 @@ - title @item.name - canonical_path @item -- localized_cache "items/#{@item.id} header" do - %header#item-header - = image_tag @item.thumbnail.secure_url, :id => 'item-thumbnail' - %div - %h2#item-name= @item.name - = nc_icon_for(@item) - - unless @item.rarity.blank? - == #{t '.rarity'}: #{@item.rarity_index} (#{@item.rarity}) - = link_to t('.resources.jn_items'), jn_items_url_for(@item) - - unless @item.nc? - = link_to t('.resources.shop_wizard'), shop_wizard_url_for(@item) - = link_to t('.resources.super_shop_wizard'), super_shop_wizard_url_for(@item) - = link_to t('.resources.trading_post'), trading_post_url_for(@item) - = link_to t('.resources.auction_genie'), auction_genie_url_for(@item) +%header#item-header + = image_tag @item.thumbnail.secure_url, :id => 'item-thumbnail' + %div + %h2#item-name= @item.name + = nc_icon_for(@item) + - unless @item.rarity.blank? + == #{t '.rarity'}: #{@item.rarity_index} (#{@item.rarity}) + = link_to t('.resources.jn_items'), jn_items_url_for(@item) + - unless @item.nc? + = link_to t('.resources.shop_wizard'), shop_wizard_url_for(@item) + = link_to t('.resources.super_shop_wizard'), super_shop_wizard_url_for(@item) + = link_to t('.resources.trading_post'), trading_post_url_for(@item) + = link_to t('.resources.auction_genie'), auction_genie_url_for(@item) - if user_signed_in? #closet-hangers @@ -47,19 +46,18 @@ t('.closet_hangers.quantity_label') = submit_tag t('.closet_hangers.submit') -- localized_cache "items/#{@item.id} info" do - %p= @item.description +%p= @item.description - #item-zones - %p - %strong #{t '.zones.occupied_header'}: - = list_zones @occupied_zones, :uncertain_label - %p - %strong #{t '.zones.restricted_header'}: - - if @restricted_zones.empty? - = t '.zones.none' - - else - = list_zones @restricted_zones +#item-zones + %p + %strong #{t '.zones.occupied_header'}: + = list_zones @occupied_zones, :uncertain_label + %p + %strong #{t '.zones.restricted_header'}: + - if @restricted_zones.empty? + = t '.zones.none' + - else + = list_zones @restricted_zones - localized_cache "items/#{@item.id} trade_hangers" do #trade-hangers @@ -73,11 +71,10 @@ %span.more= t '.trading_closet_hangers.show_more' %span.less= t '.trading_closet_hangers.show_less' -- localized_cache 'items#show preview_header' do - #item-preview-header - %h3= t '.preview.header' - = link_to t('.preview.customize_more'), root_path, :id => 'customize-more', - :class => 'button' +#item-preview-header + %h3= t '.preview.header' + = link_to t('.preview.customize_more'), root_path, :id => 'customize-more', + :class => 'button' #item-preview %ul#item-preview-species{'data-supported-species-ids' => @supported_species_ids.join(',')}