diff options
author | Rémy Coutable <remy@rymai.me> | 2019-02-04 18:59:34 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-02-05 11:10:54 +0100 |
commit | 787cbc89769a6d2f2568187cc987ba9308346c21 (patch) | |
tree | 1129db7d0f6faf0aa07318e20ffcb793231ccbc1 | |
parent | 068b41275f6f142acfddca273ace68d03a6c0730 (diff) | |
download | gitlab-ce-787cbc89769a6d2f2568187cc987ba9308346c21.tar.gz |
Reduce diff with EE in Search::GlobalService
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | app/services/search/global_service.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb index cb1bf0a03a5..d6af26d949d 100644 --- a/app/services/search/global_service.rb +++ b/app/services/search/global_service.rb @@ -2,6 +2,8 @@ module Search class GlobalService + include Gitlab::Utils::StrongMemoize + attr_accessor :current_user, :params attr_reader :default_project_filter @@ -19,11 +21,15 @@ module Search @projects ||= ProjectsFinder.new(current_user: current_user).execute end - def scope - @scope ||= begin - allowed_scopes = %w[issues merge_requests milestones] + def allowed_scopes + strong_memoize(:allowed_scopes) do + %w[issues merge_requests milestones] + end + end - allowed_scopes.delete(params[:scope]) { 'projects' } + def scope + strong_memoize(:scope) do + allowed_scopes.include?(params[:scope]) ? params[:scope] : 'projects' end end end |