implemented moderator dashboard queue
This commit is contained in:
30
app/logical/moderator/dashboard/queries/artist.rb
Normal file
30
app/logical/moderator/dashboard/queries/artist.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class Artist
|
||||
attr_reader :user, :count
|
||||
|
||||
def self.all(min_date, max_level)
|
||||
sql = <<-EOS
|
||||
SELECT artist_versions.updater_id AS user_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
|
||||
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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4,8 +4,27 @@ module Moderator
|
||||
class Comment
|
||||
attr_reader :comment, :count
|
||||
|
||||
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
|
||||
HAVING count(*) >= 3
|
||||
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)
|
||||
@comment = Comment.find(hash["comment_id"])
|
||||
@comment = ::Comment.find(hash["comment_id"])
|
||||
@count = hash["count"]
|
||||
end
|
||||
end
|
||||
|
||||
11
app/logical/moderator/dashboard/queries/mod_action.rb
Normal file
11
app/logical/moderator/dashboard/queries/mod_action.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class ModAction
|
||||
def self.all
|
||||
::ModAction.order("id desc").limit(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
30
app/logical/moderator/dashboard/queries/note.rb
Normal file
30
app/logical/moderator/dashboard/queries/note.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
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
|
||||
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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class Post
|
||||
attr_reader :post, :count
|
||||
|
||||
def initialize(hash)
|
||||
@post = Post.find(hash["post_id"])
|
||||
@count = hash["count"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,7 @@ module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class PostAppeal
|
||||
attr_reader :post, :reason
|
||||
attr_reader :post, :count
|
||||
|
||||
def self.all(min_date)
|
||||
sql = <<-EOS
|
||||
@@ -11,7 +11,8 @@ module Moderator
|
||||
JOIN posts ON posts.id = post_appeals.post_id
|
||||
WHERE
|
||||
post_appeals.created_at > ?
|
||||
and posts.status <> ?
|
||||
and posts.is_deleted = true
|
||||
and posts.is_pending = false
|
||||
GROUP BY post_appeals.post_id
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
@@ -21,8 +22,8 @@ module Moderator
|
||||
end
|
||||
|
||||
def initialize(hash)
|
||||
@post = Post.find(hash["post_id"])
|
||||
@reason = hash["reason"]
|
||||
@post = ::Post.find(hash["post_id"])
|
||||
@count = hash["count"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,8 @@ module Moderator
|
||||
WHERE
|
||||
post_flags.created_at > ?
|
||||
AND post_flags.reason <> ?
|
||||
AND posts.status <> 'deleted'
|
||||
AND posts.is_deleted = false
|
||||
and posts.is_pending = false
|
||||
GROUP BY post_flags.post_id
|
||||
ORDER BY count(*) DESC
|
||||
LIMIT 10
|
||||
|
||||
32
app/logical/moderator/dashboard/queries/tag.rb
Normal file
32
app/logical/moderator/dashboard/queries/tag.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
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.created_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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,10 +2,27 @@ module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class Upload
|
||||
def self.all(min_date)
|
||||
ActiveRecord::Base.without_timeout do
|
||||
@upload_activity = ActiveRecord::Base.select_all_sql("select posts.uploader_string, count(*) from posts join users on posts.user_id = users.id where posts.created_at > ? and users.level <= ? group by posts.user_id order by count(*) desc limit 10", min_date, max_level).map {|x| UserActivity.new(x)}
|
||||
end
|
||||
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
|
||||
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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class User
|
||||
attr_reader :user, :count
|
||||
|
||||
def initialize(hash)
|
||||
@user = User.find(hash["user_id"])
|
||||
@count = hash["count"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
11
app/logical/moderator/dashboard/queries/user_feedback.rb
Normal file
11
app/logical/moderator/dashboard/queries/user_feedback.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class UserFeedback
|
||||
def self.all
|
||||
::UserFeedback.order("id desc").limit(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
30
app/logical/moderator/dashboard/queries/wiki_page.rb
Normal file
30
app/logical/moderator/dashboard/queries/wiki_page.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
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
|
||||
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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,52 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
class Report
|
||||
attr_reader :min_date, :max_level
|
||||
|
||||
def initialize(min_date, max_level)
|
||||
@min_date = min_date
|
||||
@max_level = max_level
|
||||
end
|
||||
|
||||
def artists
|
||||
Queries::Artist.all(min_date, max_level)
|
||||
end
|
||||
|
||||
def comments
|
||||
Queries::Comment.all(min_date, max_level)
|
||||
end
|
||||
|
||||
def mod_actions
|
||||
Queries::ModAction.all
|
||||
end
|
||||
|
||||
def notes
|
||||
Queries::Note.all(min_date, max_level)
|
||||
end
|
||||
|
||||
def appeals
|
||||
Queries::PostAppeal.all(min_date)
|
||||
end
|
||||
|
||||
def flags
|
||||
Queries::PostFlag.all(min_date)
|
||||
end
|
||||
|
||||
def tags
|
||||
Queries::Tag.all(min_date, max_level)
|
||||
end
|
||||
|
||||
def posts
|
||||
Queries::Upload.all(min_date, max_level)
|
||||
end
|
||||
|
||||
def user_feedbacks
|
||||
Queries::UserFeedback.all
|
||||
end
|
||||
|
||||
def wiki_pages
|
||||
Queries::WikiPage.all(min_date, max_level)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
class ModeratorDashboard
|
||||
attr_reader :min_date, :max_level
|
||||
|
||||
def initialize(min_date, max_level)
|
||||
@min_date = min_date
|
||||
@max_level = max_level
|
||||
end
|
||||
|
||||
def upload_activity
|
||||
|
||||
|
||||
@upload_activity
|
||||
end
|
||||
|
||||
def comment_activity(positive = false)
|
||||
if positive
|
||||
ActiveRecord::Base.select_all_sql("SELECT comment_votes.comment_id, count(*) FROM comment_votes JOIN comments ON comments.id = comment_votes.comment_id JOIN users ON users.id = comments.user_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 LIMIT 10", min_date, max_level).map {|x| CommentActivity.new(x)}
|
||||
else
|
||||
ActiveRecord::Base.select_all_sql("SELECT comment_votes.comment_id, count(*) FROM comment_votes JOIN comments ON comments.id = comment_votes.comment_id JOIN users ON users.id = comments.user_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 LIMIT 10", min_date, max_level).map {|x| CommentActivity.new(x)}
|
||||
end
|
||||
end
|
||||
|
||||
def post_activity(positive = false)
|
||||
ActiveRecord::Base.without_timeout do
|
||||
if positive
|
||||
@post_activity = ActiveRecord::Base.select_all_sql("SELECT post_votes.post_id, count(*) FROM post_votes JOIN posts ON posts.id = post_votes.post_id JOIN users ON users.id = posts.user_id WHERE post_votes.created_at > ? AND posts.score > 0 AND users.level <= ? GROUP BY post_votes.post_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| PostActivity.new(x)}
|
||||
else
|
||||
@post_activity = ActiveRecord::Base.select_all_sql("SELECT post_votes.post_id, count(*) FROM post_votes JOIN posts ON posts.id = post_votes.post_id JOIN users ON users.id = posts.user_id WHERE post_votes.created_at > ? AND posts.score < 0 AND users.level <= ? AND posts.status <> 'deleted' GROUP BY post_votes.post_id HAVING count(*) >= 3 ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| PostActivity.new(x)}
|
||||
end
|
||||
end
|
||||
|
||||
@post_activity
|
||||
end
|
||||
|
||||
def tag_activity
|
||||
ActiveRecord::Base.without_timeout do
|
||||
@tag_activity = ActiveRecord::Base.select_all_sql("SELECT post_tag_histories.user_id, count(*) FROM post_tag_histories JOIN users ON users.id = post_tag_histories.user_id WHERE post_tag_histories.created_at > ? AND users.level <= ? GROUP BY post_tag_histories.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
|
||||
end
|
||||
|
||||
@tag_activity
|
||||
end
|
||||
|
||||
def note_activity
|
||||
ActiveRecord::Base.select_all_sql("SELECT note_versions.user_id, count(*) FROM note_versions JOIN users ON users.id = note_versions.user_id WHERE note_versions.created_at > ? AND users.level <= ? GROUP BY note_versions.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
|
||||
end
|
||||
|
||||
def wiki_page_activity
|
||||
ActiveRecord::Base.select_all_sql("SELECT wiki_page_versions.user_id, count(*) FROM wiki_page_versions JOIN users ON users.id = wiki_page_versions.user_id WHERE wiki_page_versions.created_at > ? AND users.level <= ? GROUP BY wiki_page_versions.user_id ORDER BY count(*) DESC LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
|
||||
end
|
||||
|
||||
def artist_activity
|
||||
ActiveRecord::Base.select_all_sql("SELECT artist_versions.updater_id AS user_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 LIMIT 10", min_date, max_level).map {|x| UserActivity.new(x)}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user