From c9e00f1d7cf9f8b2cb503d92e9d2a368670f22e2 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 12:04:09 -0700 Subject: [PATCH] Stop caching latest contribution That's another tiny query that I'm okay with just removing the cache overhead complexity for right now! --- app/controllers/outfits_controller.rb | 6 ++---- app/models/contribution_observer.rb | 2 -- app/views/outfits/new.html.haml | 11 +++++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index 1a42cc5c..3b11f44f 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -69,10 +69,8 @@ class OutfitsController < ApplicationController @species_count = Species.count - unless localized_fragment_exist?('outfits#new latest_contribution') - @latest_contribution = Contribution.recent.first - Contribution.preload_contributeds_and_parents([@latest_contribution].compact) - end + @latest_contribution = Contribution.recent.first + Contribution.preload_contributeds_and_parents([@latest_contribution].compact) @neopets_usernames = user_signed_in? ? current_user.neopets_usernames : [] diff --git a/app/models/contribution_observer.rb b/app/models/contribution_observer.rb index 2c232cdc..88d7fa06 100644 --- a/app/models/contribution_observer.rb +++ b/app/models/contribution_observer.rb @@ -2,8 +2,6 @@ class ContributionObserver < ActiveRecord::Observer include FragmentExpiration def after_create(contribution) - expire_fragment_in_all_locales('outfits#new latest_contribution') - if contribution.contributed_type == 'SwfAsset' item = contribution.contributed.item expire_fragment_in_all_locales("items/#{item.id} contributors") diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index d086efb6..4cc0acc8 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -92,12 +92,11 @@ required: true = submit_tag t('.modeling_hub.load_pet.submit') -- localized_cache 'outfits#new latest_contribution' do - - if @latest_contribution # will be nil for a fresh copy of the site ;P - #latest-contribution - = link_to t('.latest_contribution.header'), contributions_path, :id => 'recent-contributions-link' - = latest_contribution_description(@latest_contribution) - %abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601} +- if @latest_contribution # will be nil for a fresh copy of the site ;P + #latest-contribution + = link_to t('.latest_contribution.header'), contributions_path, :id => 'recent-contributions-link' + = latest_contribution_description(@latest_contribution) + %abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601} #whats-new - if @newest_unmodeled_items.present?