2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-25 09:41:28 -05:00
|
|
|
module Gitlab
|
2017-05-31 01:50:53 -04:00
|
|
|
module SlashCommands
|
2016-11-25 09:41:28 -05:00
|
|
|
class IssueSearch < IssueCommand
|
|
|
|
def self.match(text)
|
|
|
|
/\Aissue\s+search\s+(?<query>.*)/.match(text)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.help_message
|
|
|
|
"issue search <your query>"
|
|
|
|
end
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-11-25 09:41:28 -05:00
|
|
|
def execute(match)
|
2017-01-10 13:43:58 -05:00
|
|
|
issues = collection.search(match[:query]).limit(QUERY_LIMIT)
|
|
|
|
|
2017-01-26 09:30:34 -05:00
|
|
|
if issues.present?
|
|
|
|
Presenters::IssueSearch.new(issues).present
|
2017-01-10 13:43:58 -05:00
|
|
|
else
|
2017-01-26 09:30:34 -05:00
|
|
|
Presenters::Access.new(issues).not_found
|
2017-01-10 13:43:58 -05:00
|
|
|
end
|
2016-11-25 09:41:28 -05:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-11-25 09:41:28 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|