#41 少々しやぅ修正

このコミットが含まれているのは:
2026-06-11 23:18:23 +09:00
コミット 4caea6213a
3個のファイルの変更204行の追加22行の削除
+24 -7
ファイルの表示
@@ -16,11 +16,12 @@ class GekanatorQuestionsController < ApplicationController
private
def question_json question
condition = condition_json(question.condition).deep_symbolize_keys
json = {
id: question_id_for(question),
text: question.text,
id: question_id_for(question, condition),
text: question_text_for(question, condition),
kind: question.kind,
condition: condition_json(question.condition),
condition: condition,
source: question.source,
priority_weight: question.priority_weight
}
@@ -30,9 +31,7 @@ class GekanatorQuestionsController < ApplicationController
json
end
def question_id_for question
condition = condition_json(question.condition).deep_symbolize_keys
def question_id_for question, condition
case condition[:type]
when 'tag'
"tag:#{ condition[:key] }"
@@ -44,8 +43,10 @@ class GekanatorQuestionsController < ApplicationController
"original-month:#{ condition[:month] }"
when 'original-month-day'
"original-month-day:#{ condition[:monthDay] || condition[:month_day] }"
when 'title-length-at-least'
"title:length-at-least:#{ condition[:length] }"
when 'title-length-greater-than'
"title:length-greater-than:#{ condition[:length] }"
"title:length-at-least:#{ condition[:length].to_i + 1 }"
when 'title-has-ascii'
'title:ascii'
when 'post-similarity'
@@ -62,9 +63,25 @@ class GekanatorQuestionsController < ApplicationController
json['monthDay'] = json.delete('month_day')
end
if json['type'] == 'title-length-greater-than'
json['type'] = 'title-length-at-least'
json['length'] = json['length'].to_i + 1
end
json
end
def question_text_for question, condition
return question.text unless question.kind == 'title'
case condition[:type]
when 'title-length-at-least'
"タイトルは #{ condition[:length] } 文字以上?"
else
question.text
end
end
def example_answers_json question
question
.gekanator_question_examples