fixing tests
This commit is contained in:
14
app/logical/moderator/dashboard/queries/comment.rb
Normal file
14
app/logical/moderator/dashboard/queries/comment.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class Comment
|
||||
attr_reader :comment, :count
|
||||
|
||||
def initialize(hash)
|
||||
@comment = Comment.find(hash["comment_id"])
|
||||
@count = hash["count"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
14
app/logical/moderator/dashboard/queries/post.rb
Normal file
14
app/logical/moderator/dashboard/queries/post.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
30
app/logical/moderator/dashboard/queries/post_appeal.rb
Normal file
30
app/logical/moderator/dashboard/queries/post_appeal.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class PostAppeal
|
||||
attr_reader :post, :reason
|
||||
|
||||
def self.all(min_date)
|
||||
sql = <<-EOS
|
||||
SELECT post_appeals.post_id, count(*)
|
||||
FROM post_appeals
|
||||
JOIN posts ON posts.id = post_appeals.post_id
|
||||
WHERE
|
||||
post_appeals.created_at > ?
|
||||
and posts.status <> ?
|
||||
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
|
||||
|
||||
def initialize(hash)
|
||||
@post = Post.find(hash["post_id"])
|
||||
@reason = hash["reason"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
31
app/logical/moderator/dashboard/queries/post_flag.rb
Normal file
31
app/logical/moderator/dashboard/queries/post_flag.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
module Queries
|
||||
class PostFlag
|
||||
attr_reader :post, :count
|
||||
|
||||
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 <> ?
|
||||
AND posts.status <> 'deleted'
|
||||
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"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
13
app/logical/moderator/dashboard/queries/upload.rb
Normal file
13
app/logical/moderator/dashboard/queries/upload.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
14
app/logical/moderator/dashboard/queries/user.rb
Normal file
14
app/logical/moderator/dashboard/queries/user.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
6
app/logical/moderator/report.rb
Normal file
6
app/logical/moderator/report.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module Moderator
|
||||
module Dashboard
|
||||
class Report
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user