From 99910aff6a423028d2a3ad1680fd620b36b13944 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 12:10:38 -0700 Subject: [PATCH] Stop caching item page contributors This lets us remove the contribution observer too! --- app/controllers/items_controller.rb | 4 +--- app/models/contribution_observer.rb | 10 ---------- app/views/items/show.html.haml | 15 +++++++-------- config/application.rb | 3 +-- 4 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 app/models/contribution_observer.rb diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index b2d12974..be691c85 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -65,9 +65,7 @@ class ItemsController < ApplicationController scope: Zone.includes_translations.alphabetical ) - unless localized_fragment_exist?("items/#{@item.id} contributors") - @contributors_with_counts = @item.contributors_with_counts - end + @contributors_with_counts = @item.contributors_with_counts @supported_species_ids = @item.supported_species_ids unless localized_fragment_exist?("items/show standard_species_images special_color=#{@item.special_color_id}") diff --git a/app/models/contribution_observer.rb b/app/models/contribution_observer.rb deleted file mode 100644 index 88d7fa06..00000000 --- a/app/models/contribution_observer.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ContributionObserver < ActiveRecord::Observer - include FragmentExpiration - - def after_create(contribution) - if contribution.contributed_type == 'SwfAsset' - item = contribution.contributed.item - expire_fragment_in_all_locales("items/#{item.id} contributors") - end - end -end diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 490bbd3c..f36d1ef0 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -84,14 +84,13 @@ #item-preview-error #item-preview-swf= t '.preview.requirements_not_met' -- localized_cache "items/#{@item.id} contributors" do - - unless @contributors_with_counts.empty? - #item-contributors - %header #{t '.contributors.header'}: - %ul - - @contributors_with_counts.each do |contributor, count| - %li= link_to(contributor.name, user_contributions_path(contributor)) + format_contribution_count(count) - %footer= t '.contributors.footer' +- unless @contributors_with_counts.empty? + #item-contributors + %header #{t '.contributors.header'}: + %ul + - @contributors_with_counts.each do |contributor, count| + %li= link_to(contributor.name, user_contributions_path(contributor)) + format_contribution_count(count) + %footer= t '.contributors.footer' :javascript var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect}, diff --git a/config/application.rb b/config/application.rb index 270ba244..4007d276 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,8 +14,7 @@ module OpenneoImpressItems # Activate observers that should always be running config.active_record.observers = [:closet_hanger_observer, - :closet_list_observer, :contribution_observer, - :pet_type_observer, :user_sweeper] + :closet_list_observer, :pet_type_observer, :user_sweeper] # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.