Skip to content

Added not_aimed_for_deletion filter for namespace-project

What does this MR do and why?

To improve the user experience in UsageQuotas page, we are no longer counting projects that have been marked for deletion in the usage quota, as the user is unable to force delete the project.

The BE effort for removing the projects that are aimed for deletion from counting towards storage was done as part of this issue.

For UI we need to provide a filter to allow UI to query for projects that are not_aimed_for_deletion.

This MR adds that filter capability in the namespace/project_finder

ref: https://gitlab.com/gitlab-org/gitlab/-/issues/414924

Screenshots or screen recordings

Screenshot_2023-06-09_at_6.01.22_PM

How to set up and validate locally

  1. Login and Visit http://localhost:3000/-/graphql-explorer
  2. Use below query, update fullPath to a valid Namespace path for your user
{
  namespace(fullPath: "gitlab-org") {
    id
    name
    projects(
      notAimedForDeletion: true
    ) {
      nodes {
        id
        fullPath
      }
    }
  }
}
  1. Validate correct output in response

Database

An index index_projects_aimed_for_deletion is already present for the new filter condition

With subgroup

With new filter condition

SELECT "projects".*, "project_statistics"."storage_size" AS project_statistics_storage_size FROM "projects" INNER JOIN "project_statistics" ON "project_statistics"."project_id" = "projects"."id" WHERE "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{4249178}'))) AND "projects"."marked_for_deletion_at" IS NULL AND "projects"."pending_delete" = FALSE ORDER BY "project_statistics"."storage_size" DESC NULLS FIRST, "projects"."id" DESC LIMIT 21

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19627/commands/64200

Original Query

SELECT "projects".*, "project_statistics"."storage_size" AS project_statistics_storage_size FROM "projects" INNER JOIN "project_statistics" ON "project_statistics"."project_id" = "projects"."id" WHERE "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{4249178}'))) ORDER BY "project_statistics"."storage_size" DESC NULLS FIRST, "projects"."id" DESC LIMIT 21

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19627/commands/64201

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 Suraj Tripathi

Merge request reports