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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.2 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
2021-09-04 01:27:46 +05:30
def initialize(project_or_projects, user, params)
@project = project_or_projects
2021-04-29 21:17:54 +05:30
@current_user = user
@params = params.dup
2014-09-02 18:07:02 +05:30
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-29 00:20:46 +05:30
order_by: params[:order_by],
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
2021-06-08 01:23:25 +05:30
Search::ProjectService.prepend_mod_with('Search::ProjectService')