How to use apply_custom_query from topic_query.rb on review page topics in plugin

hello,

I have a plugin that makes use of the TopicQuery.add_custom_filter function.

It applies my custom filter as expected only to the default view of topics displayed on the landing page.

I noticed this is because in the topic_query.rb file under the defualt_results method there is a call to apply my custom filters with

    result = apply_ordering(result, options)

this is great, but not exactly what I wanted. I wanted to have that filter applied to anything showing up under the /review page. I’m not sure how I would do this.

is anyone familiar with this part of the code?

the way I am currently filtering can be seen here:
https://github.com/hms-networks/discourse-location-filters/blob/test/app/controllers/filter_controller.rb

and the discourse rb file I am talking about is this one:

1 Like

I guess I messed up when I started going down this topic query path because it looks like reviewables doesn’t even use those topic query functions so I cant apply a custom filter this way.

also, I am still a little confused about what the parameters of apply_custom_filters are. do results refer to a ruby hash of topics? and is topic_query just an instance of the class?

Moving forward I’m not sure if this is the correct way to do this but I will try to find out how I can overwrite the reviewables_controller#index function to remove topics from the reviewables list depending on the current user.

advice and suggestions here would be cool :slight_smile:

1 Like