Module: TheComments::User
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/the_comments/user.rb
Instance Method Summary collapse
- #comcoms_sum ⇒ Object
- #comments_sum ⇒ Object
- #my_comments ⇒ Object
- #my_spam_comments ⇒ Object
- #recalculate_comcoms_counters! ⇒ Object
-
#recalculate_my_comments_counter! ⇒ Object
I think we shouldn’t to have my_deleted_comments cache counter.
- #update_comcoms_spam_counter ⇒ Object
Instance Method Details
#comcoms_sum ⇒ Object
52 53 54 |
# File 'app/models/concerns/the_comments/user.rb', line 52 def comcoms_sum published_comcoms_count + draft_comcoms_count end |
#comments_sum ⇒ Object
48 49 50 |
# File 'app/models/concerns/the_comments/user.rb', line 48 def comments_sum published_comments_count + draft_comments_count end |
#my_comments ⇒ Object
9 |
# File 'app/models/concerns/the_comments/user.rb', line 9 def my_comments; ::Comment.where(user: self); end |
#my_spam_comments ⇒ Object
21 22 23 |
# File 'app/models/concerns/the_comments/user.rb', line 21 def my_spam_comments my_comments.where(spam: true) end |
#recalculate_comcoms_counters! ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/models/concerns/the_comments/user.rb', line 36 def recalculate_comcoms_counters! update_attributes!({ draft_comcoms_count: draft_comcoms.count, published_comcoms_count: published_comcoms.count, deleted_comcoms_count: deleted_comcoms.count }) end |
#recalculate_my_comments_counter! ⇒ Object
I think we shouldn’t to have my_deleted_comments cache counter
26 27 28 29 30 31 32 33 34 |
# File 'app/models/concerns/the_comments/user.rb', line 26 def recalculate_my_comments_counter! dcount = my_draft_comments.count pcount = my_published_comments.count update_attributes!({ my_draft_comments_count: dcount, my_published_comments_count: pcount, my_comments_count: dcount + pcount }) end |
#update_comcoms_spam_counter ⇒ Object
44 45 46 |
# File 'app/models/concerns/the_comments/user.rb', line 44 def update_comcoms_spam_counter update!(spam_comcoms_count: comcoms.where(spam: true).count) end |