Stop caching item page contributors

This lets us remove the contribution observer too!
This commit is contained in:
Matchu 2023-08-02 12:10:38 -07:00
parent f277ad9ffd
commit 99910aff6a
4 changed files with 9 additions and 23 deletions

View file

@ -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}")

View file

@ -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

View file

@ -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},

View file

@ -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.