Skip to content

Add ability to search iterations by cadence title

euko requested to merge 336611-search-iterations-by-cadence-title into master

What does this MR do and why?

Resolves #336611 (closed) and #346993 (closed)

  • Adds ability to search iterations using the fields iteration title or iteration's cadence title using GraphQL.
  • Adds a new sort order CADENCE_AND_DUE_DATE_ASC.
  • Don't use use_minimum_char_limit when searching iterations/cadence titles (specifically addresses #346993 (closed)) when a query includes a numeric character.

Sample graphql query with corresponding DB query:

This is the most likely used variant in production by a wide margin. The use case is searching iterations in the sidebar dropdown where we only need open i.e., state_enum IN (1,2) iterations.

GraphQL query:

{
  group(fullPath: "public-group-1") {
    iterations(search: "plan", in: [TITLE, CADENCE_TITLE], sort: CADENCE_AND_DUE_DATE_ASC, state: opened) {
      nodes {
	id
        title
        iterationCadence {
          id
          title
        }
        dueDate
        state
      }
    }
  }
}

GraphQL response:

{
  "data": {
    "group": {
      "iterations": {
        "nodes": [
          {
            "id": "gid://gitlab/Iteration/4010",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-18",
            "state": "current"
          },
          {
            "id": "gid://gitlab/Iteration/4011",
            "title": "Iteration 2",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-25",
            "state": "upcoming"
          },
          {
            "id": "gid://gitlab/Iteration/4012",
            "title": "Iteration 3",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-02-01",
            "state": "upcoming"
          },
          {
            "id": "gid://gitlab/Iteration/4013",
            "title": "Iteration 4",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-02-08",
            "state": "upcoming"
          }
        ]
      }
    }
  }
}

DB query plan: https://explain-depesz.postgres.ai/s/CV

Sample GraphQL & DB query 2

Searching iterations by cadence titles.

{
   group(fullPath: "public-group-1") {
    iterations(search: "stage", in: [CADENCE_TITLE], sort: CADENCE_AND_DUE_DATE_ASC) {
      nodes {
	id
        title
        iterationCadence {
          id
          title
        }
        dueDate
        state
      }
    }
  }
}

GraphQL response:

{
  "data": {
    "group": {
      "iterations": {
        "nodes": [
          {
            "id": "gid://gitlab/Iteration/4010",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-18",
            "state": "current"
          },
          {
            "id": "gid://gitlab/Iteration/4011",
            "title": "Iteration 2",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-25",
            "state": "upcoming"
          },
          {
            "id": "gid://gitlab/Iteration/4012",
            "title": "Iteration 3",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-02-01",
            "state": "upcoming"
          },
          {
            "id": "gid://gitlab/Iteration/4013",
            "title": "Iteration 4",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-02-08",
            "state": "upcoming"
          }
        ]
      }
    }
  }
}

DB query plan: https://explain-depesz.postgres.ai/s/Xp

Sample GraphQL & DB query 3

Searching iterations by title (note that we already had this.)

GraphQL query:

{
  "data": {
    "project": {
      "iterations": {
        "nodes": [
          {
            "id": "gid://gitlab/Iteration/3999",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8003",
              "title": "Automated Cadence"
            },
            "dueDate": "2022-01-07",
            "state": "closed"
          },
          {
            "id": "gid://gitlab/Iteration/4010",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-18",
            "state": "current"
          }
        ]
      }
    }
  }
}

GraphQL response:

{
  "data": {
    "project": {
      "iterations": {
        "nodes": [
          {
            "id": "gid://gitlab/Iteration/3999",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8003",
              "title": "Automated Cadence"
            },
            "dueDate": "2022-01-07",
            "state": "closed"
          },
          {
            "id": "gid://gitlab/Iteration/4010",
            "title": "Iteration 1",
            "iterationCadence": {
              "id": "gid://gitlab/Iterations::Cadence/8005",
              "title": "Plan stage"
            },
            "dueDate": "2022-01-18",
            "state": "current"
          }
        ]
      }
    }
  }
}

DB query plan: https://explain-depesz.postgres.ai/s/MO

How to set up and validate locally

Iteration cadences is a new feature currently in development behind the FF :iteration_cadences. An iteration cadence is a container for a set of iterations. Note that every iteration belongs to some iteration cadence at the database level although user may not be able to interact with cadence-related features through UI.

For the purpose of testing, we need to create and query multiple iteration cadences after enabling the FF. However, the changes made in this MR should work with/without the feature flag all the same.

  1. Enable :iteration_cadences

    Feature.enable(:iteration_cadences)
  2. Navigate to Iteration Cadences page using the left side bar. Issues > Iteration and create cadences/iterations https://docs.gitlab.com/ee/user/group/iterations/#iteration-cadences

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 euko

Merge request reports

Loading