# Class SearchContext < Object

- app/contexts/search_context.rb

Methods

E
  - execute
N
  - new
R
  - result

Attributes

[RW] | params |
[RW] | project_ids |

Class Public methods
new(project_ids, params) Link

Source: show

    # File app/contexts/search_context.rb, line 4
    def initialize(project_ids, params)
      @project_ids, @params = project_ids, params.dup
    end

Instance Public methods
execute() Link

Source: show

    # File app/contexts/search_context.rb, line 8
    def execute
      query = params[:search]

      return result unless query.present?

      result[:projects] = Project.where(id: project_ids).search(query).limit(10)
      result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10)
      result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10)
      result[:wiki_pages] = Wiki.where(project_id: project_ids).search(query).limit(10)
      result
    end

result() Link

Source: show

    # File app/contexts/search_context.rb, line 20
    def result
      @result ||= {
        projects: [],
        merge_requests: [],
        issues: [],
        wiki_pages: []
      }
    end