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

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

      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
    end
  end
end