implemented moderator dashboard queue

This commit is contained in:
albert
2011-07-22 17:34:43 -04:00
parent 4828cef27d
commit d0e8084f0f
41 changed files with 710 additions and 330 deletions

View File

@@ -4,8 +4,27 @@ module Moderator
class Comment
attr_reader :comment, :count
def self.all(min_date, max_level)
sql = <<-EOS
SELECT comment_votes.comment_id, count(*)
FROM comment_votes
JOIN comments ON comments.id = comment_id
JOIN users ON users.id = comments.creator_id
WHERE
comment_votes.created_at > ?
AND comments.score < 0
AND users.level <= ?
GROUP BY comment_votes.comment_id
HAVING count(*) >= 3
ORDER BY count(*) DESC
LIMIT 10
EOS
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
end
def initialize(hash)
@comment = Comment.find(hash["comment_id"])
@comment = ::Comment.find(hash["comment_id"])
@count = hash["count"]
end
end