self.summary what

in models/content.rb [71:106]


  def self.summary what
    
    

    answer = {}
    vote_count = 0
    thread_count = 0
    comment_count = 0
    contributors = []
    content = self.where(what)

    content.each do |c|
      contributors << c.author_id
      contributors << c['votes']['up']
      contributors << c['votes']['down']
      vote_count += c['votes']['count']
      if c._type == 'CommentThread'
        thread_count += 1
      elsif c._type == 'Comment'
        comment_count += 1
      end
    end

    
    contributors = contributors.uniq

    

    answer['vote_count'] = vote_count
    answer['thread_count'] = thread_count
    answer['comment_count'] = comment_count
    answer['contributor_count'] = contributors.count

    answer
  end