Merge pull request #2926 from evazion/fix-mod-dashboard
Fix post version reference on /moderator/dashboard
This commit is contained in:
@@ -5,26 +5,17 @@ module Moderator
|
|||||||
attr_reader :user, :count
|
attr_reader :user, :count
|
||||||
|
|
||||||
def self.all(min_date, max_level)
|
def self.all(min_date, max_level)
|
||||||
sql = <<-EOS
|
return unless PostArchive.enabled?
|
||||||
SELECT post_versions.updater_id, count(*)
|
|
||||||
FROM post_versions
|
|
||||||
JOIN users ON users.id = post_versions.updater_id
|
|
||||||
WHERE
|
|
||||||
post_versions.updated_at > ?
|
|
||||||
AND users.level <= ?
|
|
||||||
GROUP BY post_versions.updater_id
|
|
||||||
ORDER BY count(*) DESC
|
|
||||||
LIMIT 10
|
|
||||||
EOS
|
|
||||||
|
|
||||||
ActiveRecord::Base.without_timeout do
|
records = PostArchive.where("updated_at > ?", min_date).group(:updater).count.map do |user, count|
|
||||||
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
|
new(user, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
records.select { |rec| rec.user.level <= max_level }.sort_by(&:count).reverse.take(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(hash)
|
def initialize(user, count)
|
||||||
@user = ::User.find(hash["updater_id"])
|
@user, @count = user, count
|
||||||
@count = hash["count"]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ module Moderator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
ActiveRecord::Base.without_timeout do
|
Queries::Tag.all(min_date, max_level)
|
||||||
Queries::Tag.all(min_date, max_level)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
|
|||||||
Reference in New Issue
Block a user