diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d22428314..aaff393ab 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -370,8 +370,11 @@ module Admin .includes(:user) .order(created_at: :desc).limit(15) - @countable_flags = calculate_countable_flags(@related_vomit_reactions) - @score = calculate_score(@related_vomit_reactions) + @user_vomit_reactions = + Reaction.where(reactable_type: "User", reactable_id: @user.id, category: "vomit") + .includes(:user) + .order(created_at: :desc) + @countable_flags = calculate_countable_flags(@user_vomit_reactions) end def user_params @@ -425,13 +428,5 @@ module Admin end countable_flags end - - def calculate_score(reactions) - score = 0 - reactions.each do |reaction| - score += reaction.points - end - score - end end end diff --git a/app/views/admin/users/show/flags/_index.html.erb b/app/views/admin/users/show/flags/_index.html.erb index 0a0464e72..7b83bd1fe 100644 --- a/app/views/admin/users/show/flags/_index.html.erb +++ b/app/views/admin/users/show/flags/_index.html.erb @@ -1,5 +1,3 @@ -<% user_vomit_reactions = @related_vomit_reactions.select { |flag| flag.reactable_type == "User" } %> -

<%= t("views.admin.users.priviliged_actions.title") %>

@@ -13,14 +11,14 @@ "> <%= crayons_icon_tag("analytics", native: true, width: 16, height: 16) %> - <%= @score %> + <%= @user.score %>
<%= render "admin/shared/flag_reactions_table", - vomit_reactions: user_vomit_reactions, + vomit_reactions: @user_vomit_reactions, text_section: "users", empty_text: t("views.admin.users.priviliged_actions.no_flags") %>