Kill trailing whitespace in ruby files
This commit is contained in:
@@ -7,16 +7,16 @@ module Moderator
|
||||
def self.all(min_date, max_level)
|
||||
sql = <<-EOS
|
||||
SELECT artist_versions.updater_id AS updater_id, count(*)
|
||||
FROM artist_versions
|
||||
JOIN users ON users.id = artist_versions.updater_id
|
||||
WHERE
|
||||
artist_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY artist_versions.updater_id
|
||||
ORDER BY count(*) DESC
|
||||
FROM artist_versions
|
||||
JOIN users ON users.id = artist_versions.updater_id
|
||||
WHERE
|
||||
artist_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY artist_versions.updater_id
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
EOS
|
||||
|
||||
|
||||
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
|
||||
end
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@ module Moderator
|
||||
|
||||
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
|
||||
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
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
EOS
|
||||
|
||||
|
||||
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
|
||||
end
|
||||
|
||||
|
||||
@@ -3,23 +3,23 @@ module Moderator
|
||||
module Queries
|
||||
class Note
|
||||
attr_reader :user, :count
|
||||
|
||||
|
||||
def self.all(min_date, max_level)
|
||||
sql = <<-EOS
|
||||
SELECT note_versions.updater_id, count(*)
|
||||
FROM note_versions
|
||||
JOIN users ON users.id = note_versions.updater_id
|
||||
WHERE
|
||||
note_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY note_versions.updater_id
|
||||
ORDER BY count(*) DESC
|
||||
SELECT note_versions.updater_id, count(*)
|
||||
FROM note_versions
|
||||
JOIN users ON users.id = note_versions.updater_id
|
||||
WHERE
|
||||
note_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY note_versions.updater_id
|
||||
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)
|
||||
@user = ::User.find(hash["updater_id"])
|
||||
@count = hash["count"]
|
||||
|
||||
@@ -10,14 +10,14 @@ module Moderator
|
||||
FROM post_appeals
|
||||
JOIN posts ON posts.id = post_appeals.post_id
|
||||
WHERE
|
||||
post_appeals.created_at > ?
|
||||
post_appeals.created_at > ?
|
||||
and posts.is_deleted = true
|
||||
and posts.is_pending = false
|
||||
GROUP BY post_appeals.post_id
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
EOS
|
||||
|
||||
|
||||
ActiveRecord::Base.select_all_sql(sql, min_date).map {|x| new(x)}
|
||||
end
|
||||
|
||||
|
||||
@@ -6,22 +6,22 @@ module Moderator
|
||||
|
||||
def self.all(min_date)
|
||||
sql = <<-EOS
|
||||
SELECT post_flags.post_id, count(*)
|
||||
FROM post_flags
|
||||
JOIN posts ON posts.id = post_flags.post_id
|
||||
WHERE
|
||||
post_flags.created_at > ?
|
||||
AND post_flags.reason <> ?
|
||||
SELECT post_flags.post_id, count(*)
|
||||
FROM post_flags
|
||||
JOIN posts ON posts.id = post_flags.post_id
|
||||
WHERE
|
||||
post_flags.created_at > ?
|
||||
AND post_flags.reason <> ?
|
||||
AND posts.is_deleted = false
|
||||
and posts.is_pending = false
|
||||
GROUP BY post_flags.post_id
|
||||
ORDER BY count(*) DESC
|
||||
GROUP BY post_flags.post_id
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
EOS
|
||||
|
||||
ActiveRecord::Base.select_all_sql(sql, min_date, "Unapproved in three days").map {|x| new(x)}
|
||||
end
|
||||
|
||||
|
||||
def initialize(hash)
|
||||
@post = Post.find(hash["post_id"])
|
||||
@count = hash["count"]
|
||||
|
||||
@@ -3,25 +3,25 @@ module Moderator
|
||||
module Queries
|
||||
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
|
||||
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
|
||||
ActiveRecord::Base.select_all_sql(sql, min_date, max_level).map {|x| new(x)}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def initialize(hash)
|
||||
@user = ::User.find(hash["updater_id"])
|
||||
@count = hash["count"]
|
||||
|
||||
@@ -3,23 +3,23 @@ module Moderator
|
||||
module Queries
|
||||
class Upload
|
||||
attr_reader :user, :count
|
||||
|
||||
|
||||
def self.all(min_date, max_level)
|
||||
sql = <<-EOS
|
||||
select uploader_id, count(*)
|
||||
from posts
|
||||
join users on uploader_id = users.id
|
||||
where
|
||||
posts.created_at > ?
|
||||
and level <= ?
|
||||
group by posts.uploader_id
|
||||
order by count(*) desc
|
||||
select uploader_id, count(*)
|
||||
from posts
|
||||
join users on uploader_id = users.id
|
||||
where
|
||||
posts.created_at > ?
|
||||
and level <= ?
|
||||
group by posts.uploader_id
|
||||
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)
|
||||
@user = ::User.find(hash["uploader_id"])
|
||||
@count = hash["count"]
|
||||
|
||||
@@ -3,23 +3,23 @@ module Moderator
|
||||
module Queries
|
||||
class WikiPage
|
||||
attr_reader :user, :count
|
||||
|
||||
|
||||
def self.all(min_date, max_level)
|
||||
sql = <<-EOS
|
||||
SELECT wiki_page_versions.updater_id, count(*)
|
||||
FROM wiki_page_versions
|
||||
JOIN users ON users.id = wiki_page_versions.updater_id
|
||||
WHERE
|
||||
wiki_page_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY wiki_page_versions.updater_id
|
||||
ORDER BY count(*) DESC
|
||||
SELECT wiki_page_versions.updater_id, count(*)
|
||||
FROM wiki_page_versions
|
||||
JOIN users ON users.id = wiki_page_versions.updater_id
|
||||
WHERE
|
||||
wiki_page_versions.created_at > ?
|
||||
AND users.level <= ?
|
||||
GROUP BY wiki_page_versions.updater_id
|
||||
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)
|
||||
@user = ::User.find(hash["updater_id"])
|
||||
@count = hash["count"]
|
||||
|
||||
@@ -2,18 +2,18 @@ module Moderator
|
||||
module Dashboard
|
||||
class Report
|
||||
attr_reader :min_date, :max_level
|
||||
|
||||
|
||||
def initialize(min_date, max_level)
|
||||
@min_date = min_date.present? ? min_date.to_date : 1.week.ago
|
||||
@max_level = max_level.present? ? User::Levels::MEMBER : max_level.to_i
|
||||
end
|
||||
|
||||
|
||||
def artists
|
||||
ActiveRecord::Base.without_timeout do
|
||||
Queries::Artist.all(min_date, max_level)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def comments
|
||||
ActiveRecord::Base.without_timeout do
|
||||
Queries::Comment.all(min_date, max_level)
|
||||
@@ -55,7 +55,7 @@ module Moderator
|
||||
Queries::Upload.all(min_date, max_level)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def user_feedbacks
|
||||
ActiveRecord::Base.without_timeout do
|
||||
Queries::UserFeedback.all
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module Moderator
|
||||
class IpAddrSearch
|
||||
attr_reader :params, :errors
|
||||
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
@errors = []
|
||||
end
|
||||
|
||||
|
||||
def execute
|
||||
if params[:user_id].present?
|
||||
search_by_user_id(params[:user_id].split(/,/))
|
||||
@@ -18,41 +18,41 @@ module Moderator
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def select_all_sql(sql, *params)
|
||||
ActiveRecord::Base.select_all_sql(sql, *params)
|
||||
end
|
||||
|
||||
|
||||
def search_by_ip_addr(ip_addrs)
|
||||
sums = Hash.new {|h, k| h[k] = 0}
|
||||
|
||||
|
||||
add_row(sums, "select creator_id as k, count(*) from comments where ip_addr in (?) group by k", ip_addrs)
|
||||
add_row(sums, "select updater_id as k, count(*) from post_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||
add_row(sums, "select updater_id as k, count(*) from note_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||
add_row(sums, "select updater_id as k, count(*) from pool_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||
add_row(sums, "select updater_id as k, count(*) from wiki_page_versions where updater_ip_addr in (?) group by k", ip_addrs)
|
||||
|
||||
|
||||
sums
|
||||
end
|
||||
|
||||
|
||||
def search_by_user_name(user_names)
|
||||
users = User.where("name in (?)", user_names)
|
||||
search_by_user_id(users.map(&:id))
|
||||
end
|
||||
|
||||
|
||||
def search_by_user_id(user_ids)
|
||||
sums = Hash.new {|h, k| h[k] = 0}
|
||||
|
||||
|
||||
add_row(sums, "select ip_addr as k, count(*) from comments where creator_id in (?) group by k", user_ids)
|
||||
add_row(sums, "select updater_ip_addr as k, count(*) from post_versions where updater_id in (?) group by k", user_ids)
|
||||
add_row(sums, "select updater_ip_addr as k, count(*) from note_versions where updater_id in (?) group by k", user_ids)
|
||||
add_row(sums, "select updater_ip_addr as k, count(*) from pool_versions where updater_id in (?) group by k", user_ids)
|
||||
add_row(sums, "select updater_ip_addr as k, count(*) from wiki_page_versions where updater_id in (?) group by k", user_ids)
|
||||
|
||||
|
||||
sums
|
||||
end
|
||||
|
||||
|
||||
def add_row(sums, sql, ip_addrs)
|
||||
select_all_sql(sql, ip_addrs).each do |row|
|
||||
sums[row["k"]] += row["count"].to_i
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
module Moderator
|
||||
class TagBatchChange < Struct.new(:antecedent, :consequent, :updater_id, :updater_ip_addr)
|
||||
class Error < Exception ; end
|
||||
|
||||
|
||||
def perform
|
||||
raise Error.new("antecedent is missing") if antecedent.blank?
|
||||
|
||||
|
||||
normalized_antecedent = TagAlias.to_aliased(::Tag.scan_tags(antecedent))
|
||||
normalized_consequent = TagAlias.to_aliased(::Tag.scan_tags(consequent))
|
||||
|
||||
|
||||
updater = User.find(updater_id)
|
||||
|
||||
|
||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||
::Post.tag_match(antecedent).each do |post|
|
||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||
|
||||
Reference in New Issue
Block a user