mirror of
https://github.com/discourse/discourse-solved.git
synced 2026-10-22 22:22:06 -04:00
DEV: Move the post and topic custom fields into a table
This PR does some preparatory work to prepare for the front-end display of who marked an answer as solved. It migrates the custom fields from discourse-solved of Topic and Post to a new table, except "accepted_answer_post_id" ref: /t/-/95318
This commit is contained in:
@@ -40,10 +40,7 @@ class DiscourseSolved::BeforeHeadClose
|
||||
},
|
||||
}
|
||||
|
||||
if accepted_answer =
|
||||
Post.find_by(
|
||||
id: topic.custom_fields[::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD],
|
||||
)
|
||||
if accepted_answer = topic.solution&.post
|
||||
question_json["answerCount"] = 1
|
||||
question_json[:acceptedAnswer] = {
|
||||
"@type" => "Answer",
|
||||
|
||||
@@ -18,12 +18,7 @@ module DiscourseSolved
|
||||
def apply_plugin_api
|
||||
plugin.register_modifier(:assigns_reminder_assigned_topics_query) do |query|
|
||||
next query if !SiteSetting.ignore_solved_topics_in_assigned_reminder
|
||||
query.where.not(
|
||||
id:
|
||||
TopicCustomField.where(
|
||||
name: ::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD,
|
||||
).pluck(:topic_id),
|
||||
)
|
||||
query.where.not(id: DiscourseSolved::Solution.pluck(:topic_id))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ::DiscourseSolved
|
||||
class Solution < ActiveRecord::Base
|
||||
belongs_to :accepter, foreign_key: :accepter_user_id, class_name: :user
|
||||
belongs_to :post, foreign_key: :answer_post_id
|
||||
belongs_to :topic
|
||||
belongs_to :topic_timer, dependent: :destroy
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user