Skip to content

Commit

Permalink
Better search job arguments (including integers) by adding `serialize…
Browse files Browse the repository at this point in the history
…d_params->>arguments` explicitly (#1504)
  • Loading branch information
bensheldon authored Oct 10, 2024
1 parent 2db3594 commit ce2dbd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/good_job/filterable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Filterable
next if query.blank?

# TODO: turn this into proper bind parameters in Arel
tsvector = "(to_tsvector('english', id::text) || to_tsvector('english', COALESCE(active_job_id::text, '')) || to_tsvector('english', serialized_params) || to_tsvector('english', COALESCE(error, '')) || to_tsvector('english', COALESCE(array_to_string(labels, ' '), '')))"
tsvector = "(to_tsvector('english', id::text) || to_tsvector('english', COALESCE(active_job_id::text, '')) || to_tsvector('english', serialized_params) || to_tsvector('english', COALESCE(serialized_params->>'arguments', '')) || to_tsvector('english', COALESCE(error, '')) || to_tsvector('english', COALESCE(array_to_string(labels, ' '), '')))"
to_tsquery_function = database_supports_websearch_to_tsquery? ? 'websearch_to_tsquery' : 'plainto_tsquery'
where("#{tsvector} @@ #{to_tsquery_function}(?)", query)
.order(sanitize_sql_for_order([Arel.sql("ts_rank(#{tsvector}, #{to_tsquery_function}(?))"), query]) => 'DESC')
Expand Down

0 comments on commit ce2dbd9

Please sign in to comment.