Skip to content

Users without possible spam contributions can be deleted immediately

Eugie Limpin requested to merge el-delete-user-without-contribs-immediately into master

What does this MR do and why?

Resolves https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/386

When a user without possible spam contributions deletes their own account their record will be deleted immediately (without 7-day delay introduced by https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/346).

Please read through this thread to have a better context for the changes in this MR.

New query

SELECT 1 AS one FROM "events" WHERE "events"."author_id" = 1614863 AND ("events"."action" = 6 OR "events"."action" = 1 AND "events"."target_type" IN ('Issue', 'MergeRequest')) LIMIT 1

Query plan: https://console.postgres.ai/shared/38f32daf-4299-4438-b0c0-880729d16448

How to set up and validate locally

  1. Turn on the feature flag
    $ rails console
    > Feature.enable(:delay_delete_own_user)
  2. Create a new user to delete
  3. Go to http://localhost:3000/-/profile/account then delete the account
  4. Validate that the user is deleted a few minutes later instead after 7 days
    > User.find(<id>)
    ActiveRecord::RecordNotFound: Couldn't find User with 'id'=<id>

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 Eugie Limpin

Merge request reports