jobs: add ability to search jobs on /jobs page.
Add ability to search jobs on the /jobs page by job type or by status. Fixes #2577 (Search filters for delayed jobs). This wasn't possible before with DelayedJobs because it stored the job data in a YAML string, which made it difficult to search jobs by type. GoodJobs stores job data in a JSON object, which is easier to search in Postgres.
This commit is contained in:
@@ -256,6 +256,8 @@ module Searchable
|
||||
case type
|
||||
when :string, :text
|
||||
search_text_attribute(name, params)
|
||||
when :uuid
|
||||
search_uuid_attribute(name, params)
|
||||
when :boolean
|
||||
search_boolean_attribute(name, params)
|
||||
when :integer, :float, :datetime, :interval
|
||||
@@ -385,6 +387,24 @@ module Searchable
|
||||
relation
|
||||
end
|
||||
|
||||
def search_uuid_attribute(attr, params)
|
||||
relation = all
|
||||
|
||||
if params[attr].present?
|
||||
relation = relation.where(attr => params[attr])
|
||||
end
|
||||
|
||||
if params[:"#{attr}_eq"].present?
|
||||
relation = relation.where(attr => params[:"#{attr}_eq"])
|
||||
end
|
||||
|
||||
if params[:"#{attr}_not_eq"].present?
|
||||
relation = relation.where.not(attr => params[:"#{attr}_not_eq"])
|
||||
end
|
||||
|
||||
relation
|
||||
end
|
||||
|
||||
def search_association_attribute(attr, params, current_user)
|
||||
association = reflect_on_association(attr)
|
||||
relation = all
|
||||
|
||||
Reference in New Issue
Block a user