diff --git a/app/controllers/maintenance/user/count_fixes_controller.rb b/app/controllers/maintenance/user/count_fixes_controller.rb new file mode 100644 index 000000000..a479132d0 --- /dev/null +++ b/app/controllers/maintenance/user/count_fixes_controller.rb @@ -0,0 +1,16 @@ +module Maintenance + module User + class CountFixesController < ApplicationController + before_action :member_only + + def new + end + + def create + CurrentUser.user.refresh_counts! + flash[:notice] = "Counts have been refreshed" + redirect_to user_path(CurrentUser.id) + end + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 5151fbd1d..247bbbc99 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -772,6 +772,16 @@ class User < ApplicationRecord def negative_feedback_count feedback.negative.count end + + def refresh_counts! + self.class.without_timeout do + update( + post_upload_count: Post.for_user(id).count, + post_update_count: PostArchive.for_user(id).count, + note_update_count: NoteVersion.for_user(id).count + ) + end + end end module SearchMethods diff --git a/app/views/maintenance/user/count_fixes/new.html.erb b/app/views/maintenance/user/count_fixes/new.html.erb new file mode 100644 index 000000000..5d318d952 --- /dev/null +++ b/app/views/maintenance/user/count_fixes/new.html.erb @@ -0,0 +1,15 @@ +
If you believe the upload counts on your profile are incorrect, you can request a refresh to recalculate the counts.
+ + <%= form_tag(maintenance_user_count_fixes_path) do %> + <%= submit_tag "Continue" %> + <% end %> +