Sha256: 02e0ce3c589ff5785800c4bc4214d2bcd0eee7e5da6adba83a35519b83ebc633
Contents?: true
Size: 1.42 KB
Versions: 27
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module GoodJob class BaseFilter DEFAULT_LIMIT = 25 EMPTY = '[none]' attr_accessor :params, :base_query def initialize(params, base_query = nil) @params = params @base_query = base_query || default_base_query end def records after_scheduled_at = params[:after_scheduled_at].present? ? Time.zone.parse(params[:after_scheduled_at]) : nil filtered_query.display_all( after_scheduled_at: after_scheduled_at, after_id: params[:after_id] ).limit(params.fetch(:limit, DEFAULT_LIMIT)) end def last @_last ||= records.last end def job_classes base_query.group("serialized_params->>'job_class'").count .sort_by { |name, _count| name.to_s } .to_h end def queues base_query.group(:queue_name).count .sort_by { |name, _count| name.to_s || EMPTY } .to_h end def states raise NotImplementedError end def to_params(override = {}) { job_class: params[:job_class], limit: params[:limit], queue_name: params[:queue_name], query: params[:query], state: params[:state], }.merge(override).delete_if { |_, v| v.blank? } end def filtered_query raise NotImplementedError end private def default_base_query raise NotImplementedError end end end
Version data entries
27 entries across 27 versions & 1 rubygems