~cytrogen/masto-fe

e4f5114aaf9cea72df735443062c26803fee0ed6 — Claire 2 years ago 5d93e98
Fix obsolete cache key in status cache invalidation logic (#26934)

3 files changed, 2 insertions(+), 10 deletions(-)

M app/models/media_attachment.rb
M app/models/poll.rb
M app/models/status_stat.rb
M app/models/media_attachment.rb => app/models/media_attachment.rb +1 -1
@@ 407,6 407,6 @@ class MediaAttachment < ApplicationRecord
  end

  def reset_parent_cache
    Rails.cache.delete("statuses/#{status_id}") if status_id.present?
    Rails.cache.delete("v3:statuses/#{status_id}") if status_id.present?
  end
end

M app/models/poll.rb => app/models/poll.rb +1 -1
@@ 108,7 108,7 @@ class Poll < ApplicationRecord
  def reset_parent_cache
    return if status_id.nil?

    Rails.cache.delete("statuses/#{status_id}")
    Rails.cache.delete("v3:statuses/#{status_id}")
  end

  def last_fetched_before_expiration?

M app/models/status_stat.rb => app/models/status_stat.rb +0 -8
@@ 16,8 16,6 @@
class StatusStat < ApplicationRecord
  belongs_to :status, inverse_of: :status_stat

  after_commit :reset_parent_cache

  def replies_count
    [attributes['replies_count'], 0].max
  end


@@ 29,10 27,4 @@ class StatusStat < ApplicationRecord
  def favourites_count
    [attributes['favourites_count'], 0].max
  end

  private

  def reset_parent_cache
    Rails.cache.delete("statuses/#{status_id}")
  end
end