Skip to content

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')

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')

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
epics_autocomplete_before epics_autocomplete_after

How to set up and validate locally

  1. In rails console enable feature flags
    Feature.enable(:namespace_level_work_items)
    Feature.enable(:cache_autocomplete_sources_issues)
  2. Visit any group and create two epics Epic A and Epic B. In a subgroup create another epic Epic C.
  3. Also create several issues in a project belonging to the same group.
  4. 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.
  5. Verify that the results include the work items epics displaying the correct icon and the subsequent calls are served from cache.
Edited by Eugenia Grieff

Merge request reports