Skip to content

Commit

Permalink
Merge pull request #2926 from evazion/fix-mod-dashboard
Browse files Browse the repository at this point in the history
Fix post version reference on /moderator/dashboard
  • Loading branch information
r888888888 committed Mar 20, 2017
2 parents 3cfacec + fe9f31d commit 9389d1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
23 changes: 7 additions & 16 deletions app/logical/moderator/dashboard/queries/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,17 @@ class Tag
attr_reader :user, :count

def self.all(min_date, max_level)
sql = <<-EOS
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
return unless PostArchive.enabled?

ActiveRecord::Base.without_timeout do
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
records = PostArchive.where("updated_at > ?", min_date).group(:updater).count.map do |user, count|
new(user, count)
end

records.select { |rec| rec.user.level <= max_level }.sort_by(&:count).reverse.take(10)
end

def initialize(hash)
@user = ::User.find(hash["updater_id"])
@count = hash["count"]
def initialize(user, count)
@user, @count = user, count
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions app/logical/moderator/dashboard/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def flags
end

def tags
ActiveRecord::Base.without_timeout do
Queries::Tag.all(min_date, max_level)
end
Queries::Tag.all(min_date, max_level)
end

def posts
Expand Down

0 comments on commit 9389d1a

Please sign in to comment.