Sha256: ae51578f1373cc3bd052094afe273ac786023352275952cf4a0a19660719b321
Contents?: true
Size: 1.41 KB
Versions: 8
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module GoodJob class JobsFilter < BaseFilter def states { 'scheduled' => base_query.scheduled.count, 'retried' => base_query.retried.count, 'queued' => base_query.queued.count, 'running' => base_query.running.count, 'finished' => base_query.finished.count, 'discarded' => base_query.discarded.count, } end def filtered_query query = base_query.includes(:executions) .joins_advisory_locks.select("#{GoodJob::ActiveJobJob.table_name}.*", 'pg_locks.locktype AS locktype') query = query.job_class(params[:job_class]) if params[:job_class].present? query = query.where(queue_name: params[:queue_name]) if params[:queue_name].present? query = query.search_text(params[:query]) if params[:query].present? if params[:state] case params[:state] when 'discarded' query = query.discarded when 'finished' query = query.finished when 'retried' query = query.retried when 'scheduled' query = query.scheduled when 'running' query = query.running.select("#{GoodJob::ActiveJobJob.table_name}.*", 'pg_locks.locktype') when 'queued' query = query.queued end end query end private def default_base_query GoodJob::ActiveJobJob.all end end end
Version data entries
8 entries across 8 versions & 1 rubygems