Files
danbooru/app/logical/moderator/dashboard/queries/comment.rb
Albert Yi 79ea6f7e6c Add Docker and Travis config files to enable CI tests
Also fixes some Rails 6.0 deprecation warnings
2018-05-09 09:56:38 -07:00

21 lines
605 B
Ruby

module Moderator
module Dashboard
module Queries
class Comment < ::Struct.new(:comment, :count)
def self.all(min_date, max_level)
::CommentVote.joins(comment: [:creator])
.where("comments.score < 0")
.where("comment_votes.created_at > ?", min_date)
.where("users.level <= ?", max_level)
.group(:comment)
.having("count(*) >= 3")
.order(Arel.sql("count(*) desc"))
.limit(10)
.count
.map { |comment, count| new(comment, count) }
end
end
end
end
end