mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-05-07 08:57:52 +00:00
Check discourse version before adding TopicQuery filters
This commit is contained in:
parent
2e4a7bc482
commit
e3cf14016f
36
plugin.rb
36
plugin.rb
@ -337,25 +337,27 @@ SQL
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require_dependency 'topic_query'
|
if Discourse.has_needed_version?(Discourse::VERSION::STRING, '1.8.0.beta6')
|
||||||
|
require_dependency 'topic_query'
|
||||||
|
|
||||||
TopicQuery.add_custom_filter(:solved) do |results, topic_query|
|
TopicQuery.add_custom_filter(:solved) do |results, topic_query|
|
||||||
if topic_query.options[:solved] == 'true'
|
if topic_query.options[:solved] == 'true'
|
||||||
results = results.where("topics.id IN (
|
results = results.where("topics.id IN (
|
||||||
SELECT tc.topic_id
|
SELECT tc.topic_id
|
||||||
FROM topic_custom_fields tc
|
FROM topic_custom_fields tc
|
||||||
WHERE tc.name = 'accepted_answer_post_id' AND
|
WHERE tc.name = 'accepted_answer_post_id' AND
|
||||||
tc.value IS NOT NULL
|
tc.value IS NOT NULL
|
||||||
)")
|
)")
|
||||||
elsif topic_query.options[:solved] == 'false'
|
elsif topic_query.options[:solved] == 'false'
|
||||||
results = results.where("topics.id NOT IN (
|
results = results.where("topics.id NOT IN (
|
||||||
SELECT tc.topic_id
|
SELECT tc.topic_id
|
||||||
FROM topic_custom_fields tc
|
FROM topic_custom_fields tc
|
||||||
WHERE tc.name = 'accepted_answer_post_id' AND
|
WHERE tc.name = 'accepted_answer_post_id' AND
|
||||||
tc.value IS NOT NULL
|
tc.value IS NOT NULL
|
||||||
)")
|
)")
|
||||||
|
end
|
||||||
|
results
|
||||||
end
|
end
|
||||||
results
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require_dependency 'topic_list_item_serializer'
|
require_dependency 'topic_list_item_serializer'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user