1
0

status_stat.rb 681 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: status_stats
  5. #
  6. # id :bigint(8) not null, primary key
  7. # status_id :bigint(8) not null
  8. # replies_count :bigint(8) default(0), not null
  9. # reblogs_count :bigint(8) default(0), not null
  10. # favourites_count :bigint(8) default(0), not null
  11. # created_at :datetime not null
  12. # updated_at :datetime not null
  13. #
  14. class StatusStat < ApplicationRecord
  15. belongs_to :status, inverse_of: :status_stat
  16. after_commit :reset_parent_cache
  17. private
  18. def reset_parent_cache
  19. Rails.cache.delete("statuses/#{status_id}")
  20. end
  21. end