Class: SolidQueueWeb::SearchController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SolidQueueWeb::SearchController
- Defined in:
- app/controllers/solid_queue_web/search_controller.rb
Constant Summary collapse
- LIMIT =
25
Constants inherited from ApplicationController
ApplicationController::PERIOD_DURATIONS
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/solid_queue_web/search_controller.rb', line 5 def index @query = params[:q].presence @job_classes = SolidQueue::Job.distinct.order(:class_name).pluck(:class_name) @results = {} return unless @query Job::EXECUTION_MODELS.each do |status, model| scope = model.includes(:job) .references(:job) .where("solid_queue_jobs.class_name LIKE ?", "%#{@query}%") .order(created_at: :desc) total = scope.count executions = scope.limit(LIMIT).to_a @results[status] = { executions: executions, total: total } unless executions.empty? end end |