Skip to content

Store abuse report labels separate from project/group labels

Eugie Limpin requested to merge el-separate-abuse-report-labels-db-table into master

Context

This MR implements a part of https://gitlab.com/gitlab-org/gitlab/-/issues/430957+ and is MR no. 3 of 3:

  1. Move base label behavior to a concern
  2. Create AbuseReportLabelType GraphQL type
  3. Store abuse report labels separate from project/group labels - 👈🏼 YOU ARE HERE

Gist of https://gitlab.com/gitlab-org/gitlab/-/issues/430957+

Abuse report labels are currently implemented as Labels and stored in labels DB table. Since these labels are for abuse reports they do not have a project_id or a group_id and should be under gitlab_main_clusterwide schema (labels is under gitlab_main_cell).

The goal is to introduce a separate model and database table for abuse report labels so that both labels and abuse report labels features are compatible with Cells 1.0.

What does this MR do and why?

This MR introduces AntiAbuse::Reports::Label and AntiAbuse::Reports::LabelLink models backed by abuse_report_labels and abuse_report_label_links DB tables. It also updates the label_links and labels association of AbuseReport to use these new models as follows:

Before
erDiagram
    AbuseReport ||--o{ LabelLink : has_many
    Label ||--o{ LabelLink : has_many
    Label {
        bigint group_id
        bigint project_id
    }
After
erDiagram
    AbuseReport ||--o{ "AntiAbuse::Reports::LabelLink": has_many
    "AntiAbuse::Reports::Label" ||--o{ "AntiAbuse::Reports::LabelLink" : has_many

Finally, Admin::AbuseReportLabel < Label model is removed and all references to it are updated to use the new AntiAbuse::Reports::Label model so abuse report labels records go to abuse_report_labels table.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. In rails console, enable the feature flag
    > Feature.enable(:abuse_report_labels)
  2. Login with an admin user (root)
  3. Go to abuse reports page (http://localhost:3000/admin/abuse_reports) and click on any abuse report
  4. Validate that creating, searching, adding, and removing labels to the abuse report works
Edited by Eugie Limpin

Merge request reports

Loading