This commit is contained in:
Toks
2013-08-13 13:33:25 -04:00
parent d83aa5de0e
commit 249ab23da5
5 changed files with 40 additions and 2 deletions

View File

@@ -26,6 +26,10 @@ class PostAppeal < ActiveRecord::Base
where("created_at >= ?", 1.day.ago)
end
def for_creator(user_id)
where("creator_id = ?", user_id)
end
def search(params)
q = scoped
return q if params.blank?

View File

@@ -27,6 +27,10 @@ class PostFlag < ActiveRecord::Base
where("created_at <= ?", 3.days.ago)
end
def for_creator(user_id)
where("creator_id = ?", user_id)
end
def search(params)
q = scoped
return q if params.blank?

View File

@@ -524,7 +524,7 @@ class User < ActiveRecord::Base
options[:except] ||= []
options[:except] += hidden_attributes
options[:methods] ||= []
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :appeal_count, :flag_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
super(options)
end
@@ -534,7 +534,7 @@ class User < ActiveRecord::Base
options[:except] ||= []
options[:except] += hidden_attributes
options[:methods] ||= []
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count, :appeal_count, :flag_count, :positive_feedback_count, :neutral_feedback_count, :negative_feedback_count]
super(options, &block)
end
@@ -569,6 +569,14 @@ class User < ActiveRecord::Base
Comment.for_creator(id).count
end
def appeal_count
PostAppeal.for_creator(id).count
end
def flag_count
PostFlag.for_creator(id).count
end
def positive_feedback_count
feedback.positive.count
end