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

31 lines
955 B
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
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],
filters: { state: params[:state] })
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
def scope
2019-07-07 11:18:12 +05:30
@scope ||= begin
allowed_scopes = %w[notes issues merge_requests milestones wiki_blobs commits]
allowed_scopes << 'users' if Feature.enabled?(:users_search, default_enabled: true)
allowed_scopes.delete(params[:scope]) { 'blobs' }
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')