|
|
@ -16,8 +16,6 @@
|
|
|
|
class StatusStat < ApplicationRecord
|
|
|
|
class StatusStat < ApplicationRecord
|
|
|
|
belongs_to :status, inverse_of: :status_stat
|
|
|
|
belongs_to :status, inverse_of: :status_stat
|
|
|
|
|
|
|
|
|
|
|
|
after_commit :reset_parent_cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def replies_count
|
|
|
|
def replies_count
|
|
|
|
[attributes['replies_count'], 0].max
|
|
|
|
[attributes['replies_count'], 0].max
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -29,10 +27,4 @@ class StatusStat < ApplicationRecord
|
|
|
|
def favourites_count
|
|
|
|
def favourites_count
|
|
|
|
[attributes['favourites_count'], 0].max
|
|
|
|
[attributes['favourites_count'], 0].max
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reset_parent_cache
|
|
|
|
|
|
|
|
Rails.cache.delete("statuses/#{status_id}")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|