summaryrefslogtreecommitdiff
path: root/lib/gitlab/slash_commands/issue_search.rb
blob: ee78f0f832ea0a56046592deaaa72c46d3aa95ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Gitlab
  module SlashCommands
    class IssueSearch < IssueCommand
      def self.match(text)
        /\Aissue\s+search\s+(?<query>.*)/.match(text)
      end

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

      # rubocop: disable CodeReuse/ActiveRecord
      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
      # rubocop: enable CodeReuse/ActiveRecord
    end
  end
end