Add facet to query and aggregate based on the work_item_type
Problem to solve
We want capability to filter and aggregates issues based on work_item_type_id for the new UI.
Proposal
We can add a param work_item_type_id and frontend can make a call for each work_item_type and can get the aggregations as well as filter them by the scope. I have added a small patch for the approach
diff --git a/app/services/concerns/search/filter.rb b/app/services/concerns/search/filter.rb
index 718318cb9124..596a221ce4ba 100644
--- a/app/services/concerns/search/filter.rb
+++ b/app/services/concerns/search/filter.rb
@@ -10,7 +10,8 @@ def filters
confidential: params[:confidential],
include_archived: params[:include_archived],
num_context_lines: params[:num_context_lines]&.to_i,
- hybrid_similarity: params[:hybrid_similarity]&.to_f
+ hybrid_similarity: params[:hybrid_similarity]&.to_f,
+ work_item_type_id: params[:work_item_type_id]&.to_i
}
end
end
diff --git a/ee/lib/gitlab/elastic/search_results.rb b/ee/lib/gitlab/elastic/search_results.rb
index a0cefb7968c8..4d70f7e19e55 100644
--- a/ee/lib/gitlab/elastic/search_results.rb
+++ b/ee/lib/gitlab/elastic/search_results.rb
@@ -380,7 +380,7 @@ def work_item_scope_options
{
klass: Issue, # For rendering the UI
index_name: ::Search::Elastic::References::WorkItem.index,
- not_work_item_type_ids: [::WorkItems::Type.find_by_name(::WorkItems::Type::TYPE_NAMES[:epic]).id]
+ work_item_type_ids: [filters[:work_item_type_id]]
},
filters.slice(:order_by, :sort, :confidential, :state, :label_name, :include_archived, :fields)
)
Adding few screenshots for the scopes
| scope | screenshot |
|---|---|
| issue | ![]() |
| requirement | ![]() |
| task | ![]() |
| incident | ![]() |
Edited by Siddharth Dungarwal



