Scope board to iteration
What does this MR do?
This is the BE part that allows to scope an issue board to an iteration or a pre-defined iteration: None, Any, Current. Stores the scoped iteration in boards#iteration_id.
Database queries of interest
[19] pry(main)> iteration = IterationsFinder.new(User.first, iterations_finder_params).find_by(id: 4)
The usual sql to pull groups in the hierarchy
------- get groups to lookup iterations within
SELECT "namespaces".*
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."id" IN (
WITH RECURSIVE "base_and_ancestors" AS (
(
SELECT "namespaces".*
FROM "namespaces"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."id" = 110
)
UNION
(
SELECT "namespaces".*
FROM "namespaces"
, "base_and_ancestors"
WHERE "namespaces"."type" = 'Group'
AND "namespaces"."id" = "base_and_ancestors"."parent_id"
)
)
SELECT "id"
FROM "base_and_ancestors" AS "namespaces"
)
Actual SQL to find the iteration
- Query plan: https://explain.depesz.com/s/HO6y
----- use above sql result to lookup iteration
SELECT "sprints".*
FROM (
(
SELECT "sprints".*
FROM "sprints"
WHERE "sprints"."project_id" = 21
)
UNION ALL
(
SELECT "sprints".*
FROM "sprints"
WHERE "sprints"."group_id" IN (107, 108, 109, 110)
)
) sprints
WHERE "sprints"."id" = 4 LIMIT 1
SQL to find iteration within gitlab project
- query plan: https://explain.depesz.com/s/5ggK
explain SELECT "sprints".*
FROM (
(
SELECT "sprints".*
FROM "sprints"
WHERE "sprints"."project_id" = 278964
)
UNION ALL
(
SELECT "sprints".*
FROM "sprints"
WHERE "sprints"."group_id" IN (9970)
)
) sprints
WHERE "sprints"."id" = 5583 LIMIT 1
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Alexandru Croitor