File tree 3 files changed +32
-0
lines changed
app/lib/plugin_initializers 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -27,4 +27,14 @@ def apply_plugin_api
27
27
end
28
28
end
29
29
end
30
+
31
+ class AssignedCountForUserQuery < PluginInitializer
32
+ def apply_plugin_api
33
+ plugin . register_modifier ( :assigned_count_for_user_query ) do |query , user |
34
+ next query if !SiteSetting . ignore_solved_topics_in_assigned_reminder
35
+ next query if SiteSetting . assignment_status_on_solve . blank?
36
+ query . where . not ( status : SiteSetting . assignment_status_on_solve )
37
+ end
38
+ end
39
+ end
30
40
end
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class Engine < ::Rails::Engine
47
47
48
48
require_relative "app/lib/plugin_initializers/assigned_reminder_exclude_solved"
49
49
DiscourseSolved ::AssignsReminderForTopicsQuery . new ( self ) . apply_plugin_api
50
+ DiscourseSolved ::AssignedCountForUserQuery . new ( self ) . apply_plugin_api
50
51
module ::DiscourseSolved
51
52
def self . accept_answer! ( post , acting_user , topic : nil )
52
53
topic ||= post . topic
Original file line number Diff line number Diff line change 532
532
expect ( topics ) . to include ( other_topic )
533
533
end
534
534
end
535
+
536
+ describe "assigned count for user" do
537
+ it "does not count solved topics using assignment_status_on_solve status" do
538
+ SiteSetting . ignore_solved_topics_in_assigned_reminder = true
539
+
540
+ other_topic = Fabricate ( :topic , title : "Topic that should be there" )
541
+ post = Fabricate ( :post , topic : other_topic , user : user )
542
+
543
+ other_topic2 = Fabricate ( :topic , title : "Topic that should be there2" )
544
+ post2 = Fabricate ( :post , topic : other_topic2 , user : user )
545
+
546
+ Assigner . new ( post . topic , user ) . assign ( user )
547
+ Assigner . new ( post2 . topic , user ) . assign ( user )
548
+
549
+ reminder = PendingAssignsReminder . new
550
+ expect ( reminder . send ( :assigned_count_for , user ) ) . to eq ( 2 )
551
+
552
+ DiscourseSolved . accept_answer! ( post2 , Discourse . system_user )
553
+ expect ( reminder . send ( :assigned_count_for , user ) ) . to eq ( 1 )
554
+ end
555
+ end
535
556
end
536
557
end
537
558
You can’t perform that action at this time.
0 commit comments