diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index 5ccb115a8..26ddd354a 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -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? diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index c87c3c6c7..646906ad2 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -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? diff --git a/app/models/user.rb b/app/models/user.rb index f8c47c5b1..2d8449712 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 12b9b3426..4ceb9d0ee 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -137,6 +137,14 @@ class UserPresenter end end + def appeal_count(template) + template.link_to(user.appeal_count, template.post_appeals_path(:search => {:creator_id => user.id})) + end + + def flag_count(template) + template.link_to(user.flag_count, template.post_flags_path(:search => {:creator_id => user.id})) + end + def approval_count(template) template.link_to(Post.where("approver_id = ?", user.id).count, template.posts_path(:tags => "approver:#{user.name}")) end diff --git a/app/views/users/_statistics.html.erb b/app/views/users/_statistics.html.erb index 8864a4a9c..db451d11e 100644 --- a/app/views/users/_statistics.html.erb +++ b/app/views/users/_statistics.html.erb @@ -92,6 +92,20 @@ + + Appeals + <%= presenter.appeal_count(self) %> + + + + <% if CurrentUser.user.id == user.id || CurrentUser.user.is_janitor? %> + + Flags + <%= presenter.flag_count(self) %> + + + <% end %> + Feedback <%= presenter.feedbacks(self) %>