このコミットが含まれているのは:
@@ -1,7 +1,7 @@
|
||||
class GekanatorQuestionExample < ApplicationRecord
|
||||
ANSWERS = GekanatorQuestionSuggestion::ANSWERS
|
||||
NON_UNKNOWN_ANSWERS = ANSWERS - ['unknown']
|
||||
SOURCES = ['initial_suggestion', 'post_game_extra'].freeze
|
||||
SOURCES = ['initial_suggestion', 'post_game_answer', 'post_game_extra'].freeze
|
||||
|
||||
belongs_to :gekanator_question
|
||||
belongs_to :post
|
||||
@@ -35,7 +35,7 @@ class GekanatorQuestionExample < ApplicationRecord
|
||||
self.answer_counts = counts
|
||||
self.sample_count = counts.values.sum
|
||||
self.gekanator_game = gekanator_game if gekanator_game.present?
|
||||
self.source = source if new_record?
|
||||
self.source = source
|
||||
|
||||
apply_aggregated_answer!(preferred_answer: answer)
|
||||
self
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class GekanatorQuestionSuggestion < ApplicationRecord
|
||||
MAX_QUESTIONS_PER_GAME = 3
|
||||
ANSWERS = ['yes', 'no', 'partial', 'probably_no', 'unknown'].freeze
|
||||
|
||||
belongs_to :gekanator_game
|
||||
@@ -10,16 +9,4 @@ class GekanatorQuestionSuggestion < ApplicationRecord
|
||||
validates :question_text, presence: true, length: { maximum: 1000 }
|
||||
validates :answer, presence: true, inclusion: { in: ANSWERS }
|
||||
validates :processed, inclusion: { in: [true, false] }
|
||||
validate :question_suggestion_limit_per_game, on: :create
|
||||
|
||||
private
|
||||
|
||||
def question_suggestion_limit_per_game
|
||||
return if gekanator_game_id.blank?
|
||||
|
||||
count = GekanatorQuestionSuggestion.where(gekanator_game_id:).count
|
||||
if count >= MAX_QUESTIONS_PER_GAME
|
||||
errors.add(:base, '質問追加数を超えてゐます.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする