The code powering m.abunchtell.com https://m.abunchtell.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

25 行
657 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: account_tag_stats
  5. #
  6. # id :bigint(8) not null, primary key
  7. # tag_id :bigint(8) not null
  8. # accounts_count :bigint(8) default(0), not null
  9. # hidden :boolean default(FALSE), not null
  10. # created_at :datetime not null
  11. # updated_at :datetime not null
  12. #
  13. class AccountTagStat < ApplicationRecord
  14. belongs_to :tag, inverse_of: :account_tag_stat
  15. def increment_count!(key)
  16. update(key => public_send(key) + 1)
  17. end
  18. def decrement_count!(key)
  19. update(key => [public_send(key) - 1, 0].max)
  20. end
  21. end