This commit is contained in:
Albert Yi
2018-06-20 11:23:44 -07:00
parent e551ff9b0c
commit 28663351d1
5 changed files with 43 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,15 @@
<div id="c-maintenance-user-count-fixes">
<div id="a-new">
<h1>Refresh Counts</h1>
<p>If you believe the upload counts on your profile are incorrect, you can request a refresh to recalculate the counts.</p>
<%= form_tag(maintenance_user_count_fixes_path) do %>
<%= submit_tag "Continue" %>
<% end %>
</div>
</div>
<% content_for(:page_title) do %>
Refresh Counts - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -119,6 +119,7 @@
<li><%= link_to("Signup", new_user_path) %></li>
<li><%= link_to("Terms of Service", terms_of_service_path) %></li>
<li><%= link_to("Upgrade Information", new_user_upgrade_path) %></li>
<li><%= link_to("Refresh counts", new_maintenance_user_count_fixes) %>
</ul>
<ul>
<li><h1>Admin</h1></li>

View File

@@ -57,6 +57,7 @@ Rails.application.routes.draw do
end
namespace :maintenance do
namespace :user do
resource :count_fixes, only: [:new, :create]
resource :email_notification, :only => [:show, :destroy]
resource :password_reset, :only => [:new, :create, :edit, :update]
resource :login_reminder, :only => [:new, :create]