Set up many-to-many assoc between AbuseReport and User (assignee)
What does this MR do and why?
This MR partially resolves https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/166?work_item_iid=511 as part of https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/166+.
It sets up associations between AbuseReport
and User
to allow assigning multiple users to abuse reports.
Note: this MR was intentionally made small to make reviews easier and more efficient. It is part of a planned series of MRs as follows:
-
Set up many-to-many assoc between AbuseReport and User (assignee)
👈🏼 You are here - Draft: Display abuse report assignees (!136038 - closed)
- [WIP] Add GraphQL endpoints to set assignees for an abuse report
- [WIP] Implement setting of assignees for an abuse report
- [WIP] Create system notes when assignees for an abuse report is updated
DB changes
Migrations
See db:check-migrations and db:check-schema jobs.
How to set up and validate locally
- Open Rails console
- Validate that multiple assignees can be added to an abuse report
[5] pry(main)> report = AbuseReport.last => #<AbuseReport:0x000000017917e038 [6] pry(main)> report.assignees => [] [7] pry(main)> report.update(assignees: [User.first, User.last]) => true [8] pry(main)> report.assignees.map(&:username) => ["root", "user4"]
- Validate that a user returns their assigned abuse reports
[9] pry(main)> user = User.first => #<User id:1 @root> [10] pry(main)> user.assigned_abuse_reports => [#<AbuseReport:0x000000017997c708 ...>] [11] pry(main)> other_user = User.last => #<User id:75 @user4> [12] pry(main)> AbuseReport.first.update(assignees: [User.last]) => true [13] pry(main)> other_user.assigned_abuse_reports => [#<AbuseReport:0x0000000179b5e620 id: 24>, #<AbuseReport:0x0000000179b5e530 id: 1>]
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Eugie Limpin