Module: TheComments::User

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/user.rb

Instance Method Summary collapse

Instance Method Details

#comcoms_sumObject



48
49
50
# File 'app/models/concerns/user.rb', line 48

def comcoms_sum
  published_comcoms_count + draft_comcoms_count
end

#comments_sumObject



44
45
46
# File 'app/models/concerns/user.rb', line 44

def comments_sum
  published_comments_count + draft_comments_count
end

#my_commentsObject



9
# File 'app/models/concerns/user.rb', line 9

def my_comments; ::Comment.where(user: self); end

#recalculate_comcoms_counters!Object



32
33
34
35
36
37
38
# File 'app/models/concerns/user.rb', line 32

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



22
23
24
25
26
27
28
29
30
# File 'app/models/concerns/user.rb', line 22

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_counterObject



40
41
42
# File 'app/models/concerns/user.rb', line 40

def update_comcoms_spam_counter
  update!(spam_comcoms_count: comcoms.where(spam: true).count)
end