Skip to content
代码片段 群组 项目
未验证 提交 70efff74 编辑于 作者: Dmitry Gruzd's avatar Dmitry Gruzd 提交者: GitLab
浏览文件

Merge branch 'fix-rubocop-elactic-search-results' into 'master'

Fix Rubocop errors for elastic search results

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/160213



Merged-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
Approved-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
Co-authored-by: default avatarArturo Herrero <arturo.herrero@gmail.com>
No related branches found
No related tags found
无相关合并请求
...@@ -405,7 +405,6 @@ Gitlab/StrongMemoizeAttr: ...@@ -405,7 +405,6 @@ Gitlab/StrongMemoizeAttr:
- 'ee/lib/gitlab/elastic/document_reference.rb' - 'ee/lib/gitlab/elastic/document_reference.rb'
- 'ee/lib/gitlab/elastic/indexer.rb' - 'ee/lib/gitlab/elastic/indexer.rb'
- 'ee/lib/gitlab/elastic/project_search_results.rb' - 'ee/lib/gitlab/elastic/project_search_results.rb'
- 'ee/lib/gitlab/elastic/search_results.rb'
- 'ee/lib/gitlab/expiring_subscription_message.rb' - 'ee/lib/gitlab/expiring_subscription_message.rb'
- 'ee/lib/gitlab/geo/health_check.rb' - 'ee/lib/gitlab/geo/health_check.rb'
- 'ee/lib/gitlab/geo/jwt_request_decoder.rb' - 'ee/lib/gitlab/geo/jwt_request_decoder.rb'
......
...@@ -46,7 +46,6 @@ Lint/SymbolConversion: ...@@ -46,7 +46,6 @@ Lint/SymbolConversion:
- 'ee/app/workers/security/store_scans_worker.rb' - 'ee/app/workers/security/store_scans_worker.rb'
- 'ee/lib/api/concerns/dependency_proxy/packages_helpers.rb' - 'ee/lib/api/concerns/dependency_proxy/packages_helpers.rb'
- 'ee/lib/ee/api/helpers.rb' - 'ee/lib/ee/api/helpers.rb'
- 'ee/lib/gitlab/elastic/search_results.rb'
- 'ee/lib/gitlab/geo/replicator.rb' - 'ee/lib/gitlab/geo/replicator.rb'
- 'ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb' - 'ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb'
- 'ee/lib/search/zoekt/search_results.rb' - 'ee/lib/search/zoekt/search_results.rb'
......
...@@ -17,7 +17,9 @@ class SearchResults ...@@ -17,7 +17,9 @@ class SearchResults
# It allows us to search only for projects user has access to # It allows us to search only for projects user has access to
attr_reader :limit_project_ids attr_reader :limit_project_ids
def initialize(current_user, query, limit_project_ids = nil, root_ancestor_ids: nil, public_and_internal_projects: true, order_by: nil, sort: nil, filters: {}) def initialize(
current_user, query, limit_project_ids = nil, root_ancestor_ids: nil,
public_and_internal_projects: true, order_by: nil, sort: nil, filters: {})
@current_user = current_user @current_user = current_user
@query = query @query = query
@limit_project_ids = limit_project_ids @limit_project_ids = limit_project_ids
...@@ -40,7 +42,6 @@ def error(scope) ...@@ -40,7 +42,6 @@ def error(scope)
issues.error issues.error
end end
# rubocop:disable Metrics/CyclomaticComplexity -- method consists of case statement only
def objects(scope, page: 1, per_page: DEFAULT_PER_PAGE, preload_method: nil) def objects(scope, page: 1, per_page: DEFAULT_PER_PAGE, preload_method: nil)
page = (page || 1).to_i page = (page || 1).to_i
...@@ -75,7 +76,6 @@ def objects(scope, page: 1, per_page: DEFAULT_PER_PAGE, preload_method: nil) ...@@ -75,7 +76,6 @@ def objects(scope, page: 1, per_page: DEFAULT_PER_PAGE, preload_method: nil)
Kaminari.paginate_array([]) Kaminari.paginate_array([])
end end
end end
# rubocop:enable Metrics/CyclomaticComplexity
# Pull the highlight attribute out of Elasticsearch results # Pull the highlight attribute out of Elasticsearch results
# and map it to the result id # and map it to the result id
...@@ -327,7 +327,8 @@ def scope_options(scope) ...@@ -327,7 +327,8 @@ def scope_options(scope)
base_options.merge(filters.slice(:include_archived)) base_options.merge(filters.slice(:include_archived))
when :merge_requests when :merge_requests
base_options base_options
.merge(filters.slice(:order_by, :sort, :state, :include_archived, :source_branch, :not_source_branch, :author_username, :not_author_username)) .merge(filters.slice(:order_by, :sort, :state, :include_archived, :source_branch, :not_source_branch,
:author_username, :not_author_username))
when :issues when :issues
base_options.merge( base_options.merge(
filters.slice(:order_by, :sort, :confidential, :state, :labels, :label_name, :include_archived), filters.slice(:order_by, :sort, :confidential, :state, :labels, :label_name, :include_archived),
...@@ -358,7 +359,7 @@ def scope_results(scope, klass, count_only:) ...@@ -358,7 +359,7 @@ def scope_results(scope, klass, count_only:)
end end
def memoize_key(scope, count_only:) def memoize_key(scope, count_only:)
count_only ? "#{scope}_results_count".to_sym : scope count_only ? :"#{scope}_results_count" : scope
end end
def projects(count_only: false) def projects(count_only: false)
...@@ -468,10 +469,9 @@ def elastic_search_limited_counter_with_delimiter(count) ...@@ -468,10 +469,9 @@ def elastic_search_limited_counter_with_delimiter(count)
end end
def blob_aggregations def blob_aggregations
strong_memoize(:blob_aggregations) do Repository.__elasticsearch__.blob_aggregations(query, base_options)
Repository.__elasticsearch__.blob_aggregations(query, base_options)
end
end end
strong_memoize_attr :blob_aggregations
def issue_aggregations def issue_aggregations
if Feature.disabled?(:search_issue_refactor, current_user) if Feature.disabled?(:search_issue_refactor, current_user)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册