Skip to content

Aggregate multiple abuse reports by the user & category (detail view)

What does this MR do and why?

Query Plans

  • Prepare the database by inserting abuse reports
/* 100 reports for user_id = 1 with status = open and category = spam */
exec INSERT INTO abuse_reports(user_id, reporter_id, status, category)
SELECT 1, generate_series(100, 200), 1, 1

/* 100 reports for user_id = 1 with status = closed and category = phishing */
exec INSERT INTO abuse_reports(user_id, reporter_id, status, category)
SELECT 1, generate_series(300, 400), 2, 2

Screenshots or screen recordings

Before After
before after

How to set up and validate locally

  1. In rails console
> Feature.enable(:abuse_reports_list)

# Seed data
> AbuseReport.delete_all

# create 2 different reports for the same user & category with status = open
> User.limit(2).order_id_asc.pluck("id").each { |i| AbuseReport.create(reporter_id: i, user_id: User.last.id, status: "open", category: "spam", message: "test") }

# create another 2 for the same user but different category but status = closed
> User.limit(2).offset(2).order_id_asc.pluck("id").each { |i| AbuseReport.create(reporter_id: i, user_id: User.last.id, status: "closed", category: "spam", message: "test") }
  1. Log-in as admin and navigate to /admin/abuse_reports

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hinam Mehra

Merge request reports

Loading