From ca19bb71faff113d129a89058d9a0e755b29b11c Mon Sep 17 00:00:00 2001 From: Lhc_fl Date: Tue, 10 Sep 2024 14:33:26 +0800 Subject: [PATCH] review: remove old_solution --- plugin.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugin.rb b/plugin.rb index a7e435c..d4e75a8 100644 --- a/plugin.rb +++ b/plugin.rb @@ -51,14 +51,12 @@ after_initialize do topic ||= post.topic DistributedMutex.synchronize("discourse_solved_toggle_answer_#{topic.id}") do - old_solution = topic.solution - - if old_solution.present? + if topic.solution.present? UserAction.where( action_type: UserAction::SOLVED, - target_post_id: old_solution.answer_post_id, + target_post_id: topic.solution.answer_post_id, ).destroy_all - old_solution.destroy! + topic.solution.destroy! end solution = DiscourseSolved::Solution.create(topic:, post:, accepter_user_id: acting_user.id)