debian-mirror-gitlab/app/services/search/project_service.rb

38 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2014-09-02 18:07:02 +05:30
module Search
class ProjectService
2021-01-03 14:25:43 +05:30
include Gitlab::Utils::StrongMemoize
ALLOWED_SCOPES = %w(notes issues merge_requests milestones wiki_blobs commits users).freeze
2014-09-02 18:07:02 +05:30
attr_accessor :project, :current_user, :params
def initialize(project, user, params)
@project, @current_user, @params = project, user, params.dup
end
def execute
2016-06-02 11:05:42 +05:30
Gitlab::ProjectSearchResults.new(current_user,
2015-04-26 12:48:37 +05:30
params[:search],
2020-11-24 15:15:51 +05:30
project: project,
repository_ref: params[:repository_ref],
2021-01-03 14:25:43 +05:30
sort: params[:sort],
filters: { confidential: params[:confidential], state: params[:state] }
)
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
2021-01-03 14:25:43 +05:30
def allowed_scopes
ALLOWED_SCOPES
end
2019-07-07 11:18:12 +05:30
2021-01-03 14:25:43 +05:30
def scope
strong_memoize(:scope) do
allowed_scopes.include?(params[:scope]) ? params[:scope] : 'blobs'
2019-07-07 11:18:12 +05:30
end
2017-08-17 22:00:37 +05:30
end
2014-09-02 18:07:02 +05:30
end
end
2019-12-04 20:38:33 +05:30
Search::ProjectService.prepend_if_ee('EE::Search::ProjectService')