Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_search.rb « slash_commands « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0a705de4484a6febef79867cbb86f5bf09a57244 (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
26
27
# frozen_string_literal: true

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