From 29ee61ab1be964a2fb0bb838b6ded5116aa6a37d Mon Sep 17 00:00:00 2001 From: xxq250 Date: Fri, 27 Sep 2024 09:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E8=AE=B0=E5=BD=95=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user_actions/_user_action_list.html.erb | 2 +- app/views/admins/user_actions/index.html.erb | 19 +------------------ ...926031029_add_user_info_to_user_actions.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index 8577b2f29..0682e9036 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -14,7 +14,7 @@ <% if user_actions.present? %> <% user_actions.each_with_index do |action, index| %> - + <%= list_index_no((params[:page] || 1).to_i, index) %> <%= action.action_name %> diff --git a/app/views/admins/user_actions/index.html.erb b/app/views/admins/user_actions/index.html.erb index 8821a8be0..bf052b146 100644 --- a/app/views/admins/user_actions/index.html.erb +++ b/app/views/admins/user_actions/index.html.erb @@ -13,24 +13,7 @@ <% end %> - - - - - - <%# @user_nps_mid = @score_total_count % 2 == 0 ? @score_total_count / 2 : (@score_total_count + 1) / 2 %> - - - - - - - - - - - - +
<%= render partial: 'admins/user_actions/user_action_list', locals: { user_actions: @user_actions } %>
diff --git a/db/migrate/202410926031029_add_user_info_to_user_actions.rb b/db/migrate/202410926031029_add_user_info_to_user_actions.rb index e361d2b1d..967e8a68d 100644 --- a/db/migrate/202410926031029_add_user_info_to_user_actions.rb +++ b/db/migrate/202410926031029_add_user_info_to_user_actions.rb @@ -7,14 +7,14 @@ class AddUserInfoToUserActions < ActiveRecord::Migration[5.2] UserAction.find_in_batches(batch_size: 1000) do |sw| Parallel.each(sw, in_threads: 5) do |user_action| - next if user_action.user_id.blank? - user = User.find_by(id: user_action.user_id) - next if user.blank? - user_action.login = user.login - user_action.email = user.mail - user_action.phone = user.phone - user_action.save + if user_action.user.present? + user_action.login = user_action.user&.login + user_action.email = user_action.user&.mail + user_action.phone = user_action.user&.phone + user_action.save + end end end end + end