Skip to content

Apply filtering of projects by topic for DORA score counts

charlie ablett requested to merge 413229-cablett-vsd-filtering into master

What does this MR do and why?

Apply filtering of projects by topic for DORA score counts

Changelog: added EE: true

How to set up and validate locally

  1. In your target group with some score counts, add topics to some of the projects (to edit, see project -> settings -> general)

Use the following query:

query {
  group(fullPath: "flightjs") {
    doraPerformanceScoreCounts(projectFilters: { topic: ["ruby", "javascript"] }) {
      nodes {
        metricName
        lowProjectsCount
        mediumProjectsCount
        highProjectsCount
        noDataProjectsCount
      }
    }
  }
}

database queries

Here's how I got the queries in console:

service = Dora::AggregateScoresService.new(container: Group.find(27), current_user: User.first, params: { topic: ["ruby", "python"] })
<some sql>
service.execute
  Projects::Topic Load (1.0ms)  SELECT "topics".* FROM "topics" WHERE "topics"."name" = 'ruby' LIMIT 1 
  Projects::Topic Load (0.2ms)  SELECT "topics".* FROM "topics" WHERE "topics"."name" = 'python' LIMIT 1 
  Project Exists? (23.6ms)  SELECT 1 AS one FROM ((SELECT "projects".* FROM "projects" WHERE "projects"."namespace_id" IN (SELECT "namespaces"."id" FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND (traversal_ids @> ('{27}'))))) projects WHERE (EXISTS (SELECT 1 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = 1 AND (project_authorizations.project_id = projects.id)) OR projects.visibility_level IN (0,10,20)))
UNION
(SELECT "projects".**"id"** FROM "projects" INNER JOIN "project_group_links" ON "projects"."id" = "project_group_links"."project_id" WHERE "project_group_links"."group_id" = 27 AND (EXISTS (SELECT 1 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = 1 AND (project_authorizations.project_id = projects.id)) OR projects.visibility_level IN (0,10,20)))) projects WHERE "projects"."pending_delete" = FALSE AND "projects"."id" IN (SELECT "project_topics"."project_id" FROM "project_topics" WHERE "project_topics"."topic_id" = 1) AND "projects"."id" IN (SELECT "project_topics"."project_id" FROM "project_topics" WHERE "project_topics"."topic_id" = 2) AND "projects"."hidden" = FALSE LIMIT 1

There's an already-existing N+1 located at https://gitlab.com/gitlab-org/gitlab/-/blob/dae3783c34ea95d609e41fc58dc54712201f2504/app/finders/projects_finder.rb#L191

MR acceptance checklist

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

Related to #413229 (closed)

Edited by charlie ablett

Merge request reports