Score and flag count fix in users profile in admin section (#19664)

* Score and flag count fix in users profile in admin section

* Used score instead of claculating it
This commit is contained in:
Rajat Talesra 2023-07-03 22:47:14 +05:30 committed by GitHub
parent 8003691b37
commit fdab1e3418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 14 deletions

View file

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

View file

@ -1,5 +1,3 @@
<% user_vomit_reactions = @related_vomit_reactions.select { |flag| flag.reactable_type == "User" } %>
<div class="flex justify-between gap-10">
<div class="flex flex-col flex-1">
<h2 class="crayons-subtitle-2 px-1"><%= t("views.admin.users.priviliged_actions.title") %></h2>
@ -13,14 +11,14 @@
<span class="crayons-card crayons-card--secondary px-3 py-1 ml-3 flex gap-2 items-center" title="<%= t("views.admin.users.flags.total_score") %>">
<%= crayons_icon_tag("analytics", native: true, width: 16, height: 16) %>
<span class="fs-s fw-medium lh-base"><%= @score %></span>
<span class="fs-s fw-medium lh-base"><%= @user.score %></span>
</span>
</div>
</div>
<div id="reaction-content" class="flex flex-col gap-3 px-1 pt-6" style="overflow: auto; height: 406px;">
<%= 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") %>
<div>