Include group-level work items in group autocomplete sources
What does this MR do and why?
When visiting a work item at the group level, the autocomplete dialogue triggered by typing #
in a comment or description will display work items at the group level.
To achieve this we modify Groups::AutocompleteService#issues
to search for work items instead of issues by using WorkItems::WorkItemsFinder
.
We also introduce the use of caching for the endpoints groups/autocomplete_sources#issues
and projects/autocomplete_sources#issues
that will expire every 3 minutes. To enable these changes both namespace_level_work_items
and cache_autocomplete_sources_issues
flags should be enabled.
Old query
IssuesFinder.new(current_user, { group_id: group.id, state: 'opened', include_subgroups: true })
.execute.preload(project: :namespace)
.with_work_item_type
.select(:iid, :title, :project_id, :namespace_id, 'work_item_types.icon_name')
- small group: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92059
- large group: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92071
New query
WorkItems::WorkItemsFinder.new(current_user, { group_id: group.id, state: 'opened', include_descendants: true })
.execute.preload(project: :namespace)
.with_work_item_type
.select(:iid, :title, :project_id, :namespace_id, 'work_item_types.icon_name')
- small group: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92076
- large group: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29659/commands/92077
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.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
![]() |
![]() |
How to set up and validate locally
- In rails console enable feature flags
Feature.enable(:namespace_level_work_items) Feature.enable(:cache_autocomplete_sources_issues)
- Visit any group and create two epics
Epic A
andEpic B
. In a subgroup create another epicEpic C
. - Also create several issues in a project belonging to the same group.
- Visit the work item view of the epic e.g
http://127.0.0.1:3000/groups/group-a/-/work_items/1
and type#
in the comment box. - Verify that the results include the work items epics displaying the correct icon and the subsequent calls are served from cache.