Add open reports count to admin overview (#13346)

* Add open reports count

* Conditionally pluralize open reports copy

* Add new scope to FeedbackMessage
This commit is contained in:
Jacob Herrington 2021-04-12 12:03:11 -05:00 committed by GitHub
parent 8aed81c739
commit c7e0b496ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -1,6 +1,9 @@
module Admin
class OverviewController < Admin::ApplicationController
layout "admin"
def index; end
def index
@open_abuse_reports_count =
FeedbackMessage.open_abuse_reports.size
end
end
end

View file

@ -13,6 +13,8 @@ class FeedbackMessage < ApplicationRecord
CATEGORIES = ["spam", "other", "rude or vulgar", "harassment", "bug", "listings"].freeze
STATUSES = %w[Open Invalid Resolved].freeze
scope :open_abuse_reports, -> { where(status: "Open", feedback_type: "abuse-reports") }
validates :feedback_type, :message, presence: true
validates :reported_url, :category, presence: { if: :abuse_report? }, length: { maximum: 250 }
validates :message, length: { maximum: 2500 }

View file

@ -22,6 +22,17 @@
</div>
</div>
</section>
<h2 class="crayons-subtitle-1 mb-3">Analytics</h2>
<article class="grid s:grid-cols-2 gap-3 mb-4" data-controller="ahoy">
<section class="crayons-card">
<div class="crayons-card__body">
<h2 class="crayons-title"><%= @open_abuse_reports_count %></h2>
<p class="crayons-subtitle-4 color-base-70">
<%= "Open report".pluralize(@open_abuse_reports_count) %>
</p>
</div>
</section>
</article>
<h2 class="crayons-subtitle-1 mb-3">Resources</h2>
<article class="grid s:grid-cols-2 gap-3" data-controller="ahoy">
<section class="crayons-card">