The way to do this is
-
On the client: Add a topic query param using
api.addDiscoveryQueryParam
-
On the server: Filter topic queries by the param using
add_custom_filter
in theTopicQuery
class (seelib/topic_query
)
The add_custom_filter callback will look a bit like this
::TopicQuery.add_custom_filter(:field_name) do |topics, query|
if query.options[:field_name]
topics.where("topics.id in (
SELECT topic_id FROM topic_custom_fields
WHERE (name = 'field_name')
AND value = '#{query.options[:field_name]}'
)")
else
topics
end
end