FEATURE: Add modifier to update the assigned count and exclude solved topics (#312)
* FEATURE: Add modifier to update the assigned count and exclude solved topics * DEV: lint solved_spec.rb
This commit is contained in:
parent
690015951e
commit
7d2a0274f9
|
@ -27,4 +27,14 @@ module DiscourseSolved
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class AssignedCountForUserQuery < PluginInitializer
|
||||||
|
def apply_plugin_api
|
||||||
|
plugin.register_modifier(:assigned_count_for_user_query) do |query, user|
|
||||||
|
next query if !SiteSetting.ignore_solved_topics_in_assigned_reminder
|
||||||
|
next query if SiteSetting.assignment_status_on_solve.blank?
|
||||||
|
query.where.not(status: SiteSetting.assignment_status_on_solve)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,6 +47,7 @@ after_initialize do
|
||||||
|
|
||||||
require_relative "app/lib/plugin_initializers/assigned_reminder_exclude_solved"
|
require_relative "app/lib/plugin_initializers/assigned_reminder_exclude_solved"
|
||||||
DiscourseSolved::AssignsReminderForTopicsQuery.new(self).apply_plugin_api
|
DiscourseSolved::AssignsReminderForTopicsQuery.new(self).apply_plugin_api
|
||||||
|
DiscourseSolved::AssignedCountForUserQuery.new(self).apply_plugin_api
|
||||||
module ::DiscourseSolved
|
module ::DiscourseSolved
|
||||||
def self.accept_answer!(post, acting_user, topic: nil)
|
def self.accept_answer!(post, acting_user, topic: nil)
|
||||||
topic ||= post.topic
|
topic ||= post.topic
|
||||||
|
|
|
@ -532,6 +532,27 @@ RSpec.describe "Managing Posts solved status" do
|
||||||
expect(topics).to include(other_topic)
|
expect(topics).to include(other_topic)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "assigned count for user" do
|
||||||
|
it "does not count solved topics using assignment_status_on_solve status" do
|
||||||
|
SiteSetting.ignore_solved_topics_in_assigned_reminder = true
|
||||||
|
|
||||||
|
other_topic = Fabricate(:topic, title: "Topic that should be there")
|
||||||
|
post = Fabricate(:post, topic: other_topic, user: user)
|
||||||
|
|
||||||
|
other_topic2 = Fabricate(:topic, title: "Topic that should be there2")
|
||||||
|
post2 = Fabricate(:post, topic: other_topic2, user: user)
|
||||||
|
|
||||||
|
Assigner.new(post.topic, user).assign(user)
|
||||||
|
Assigner.new(post2.topic, user).assign(user)
|
||||||
|
|
||||||
|
reminder = PendingAssignsReminder.new
|
||||||
|
expect(reminder.send(:assigned_count_for, user)).to eq(2)
|
||||||
|
|
||||||
|
DiscourseSolved.accept_answer!(post2, Discourse.system_user)
|
||||||
|
expect(reminder.send(:assigned_count_for, user)).to eq(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue