Class: Gitlab::SlashCommands::IssueSearch

Inherits:
IssueCommand show all
Defined in:
lib/gitlab/slash_commands/issue_search.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::QUERY_LIMIT

Instance Attribute Summary

Attributes inherited from BaseCommand

#chat_name, #current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IssueCommand

available?, #collection

Methods inherited from BaseCommand

allowed?, available?, can?, #collection, #initialize

Constructor Details

This class inherits a constructor from Gitlab::SlashCommands::BaseCommand

Class Method Details

.help_messageObject


10
11
12
# File 'lib/gitlab/slash_commands/issue_search.rb', line 10

def self.help_message
  "issue search <your query>"
end

.match(text) ⇒ Object


6
7
8
# File 'lib/gitlab/slash_commands/issue_search.rb', line 6

def self.match(text)
  /\Aissue\s+search\s+(?<query>.*)/.match(text)
end

Instance Method Details

#execute(match) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/slash_commands/issue_search.rb', line 15

def execute(match)
  issues = collection.search(match[:query]).limit(QUERY_LIMIT)

  if issues.present?
    Presenters::IssueSearch.new(issues).present
  else
    Presenters::Access.new(issues).not_found
  end
end