Skip to content

Add label filter to milestones

What does this MR do and why?

Currently, when viewing a group's roadmap, filtering by label does not filter milestones. Here we are adding this filter, allowing one to filter miltestones that have issues which have the specified labels.

Related to #223018

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.

How to set up and validate locally

  1. Create a group with a project, several milestones, epics, issues and labels
  2. Assign the issues to various milestones and epics
  3. Add labels to the issues
  4. In your GraphiQL explorer, run this query (in this example, my namespace is called milestones, and I am searching for a label named red:
query groupMilestonesEE {
  group(fullPath: "milestones") {
    id
    name
    milestones (labelNames: ["red"]) {
      nodes {
        id
        title
      }
    }
  }
  
  1. This should only return milestones that contain issues which have this label assigned to them.

Raw SQL Query

SELECT DISTINCT
    milestones.*
FROM
    (
        (
            SELECT
                milestones.*
            FROM
                milestones
            WHERE
                milestones.project_id IN ( 13083, 278964 )
        )
        UNION ALL
        (
            SELECT
                milestones.*
            FROM
                milestones
            WHERE
                milestones.group_id = 9970
        )
    ) AS milestones
    JOIN issues ON issues.milestone_id = milestones.id
    JOIN label_links ON label_links.target_type = 'Issue' AND
    label_links.target_id = issues.id
    JOIN labels ON labels.id = label_links.label_id
WHERE
    labels.title = 'label1'; 

Query Plan

https://postgres.ai/console/gitlab/gitlab-production-main/sessions/28131/commands/87871

Edited by Joseph Wambua

Merge request reports