Files
danbooru/app/logical/moderator/dashboard/queries/comment.rb
evazion a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00

24 lines
649 B
Ruby

# frozen_string_literal: true
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