1
0

status_stat.rb 765 B

123456789101112131415161718192021222324252627282930
  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. def replies_count
  17. [attributes['replies_count'], 0].max
  18. end
  19. def reblogs_count
  20. [attributes['reblogs_count'], 0].max
  21. end
  22. def favourites_count
  23. [attributes['favourites_count'], 0].max
  24. end
  25. end