このコミットが含まれているのは:
@@ -206,6 +206,40 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
expect(example.gekanator_game_id).to eq(json['id'])
|
||||
end
|
||||
|
||||
it 'learns accepted post_similarity answers from main game logs' do
|
||||
sign_in_as admin
|
||||
|
||||
question = create_post_similarity_question!(text: '泣いてる?')
|
||||
|
||||
expect {
|
||||
post '/gekanator/games', params: {
|
||||
guessed_post_id: guessed_post.id,
|
||||
correct_post_id: correct_post.id,
|
||||
answers: [
|
||||
{
|
||||
question_id: "post-similarity:#{question.id}",
|
||||
question_text: '泣いてる?',
|
||||
answer: 'partial',
|
||||
original_answer: 'partial'
|
||||
}
|
||||
]
|
||||
}
|
||||
}.to change { GekanatorQuestionExample.count }.by(1)
|
||||
|
||||
expect(response).to have_http_status(:created)
|
||||
expect(json['learned_example_count']).to eq(1)
|
||||
|
||||
example = GekanatorQuestionExample.last
|
||||
expect(example).to have_attributes(
|
||||
gekanator_question_id: question.id,
|
||||
post_id: correct_post.id,
|
||||
user_id: admin.id,
|
||||
answer: 'partial',
|
||||
source: 'post_game_answer'
|
||||
)
|
||||
expect(example.gekanator_game_id).to eq(json['id'])
|
||||
end
|
||||
|
||||
it 'does not learn fact questions or nico tag questions from main game logs' do
|
||||
sign_in_as admin
|
||||
|
||||
@@ -550,6 +584,37 @@ RSpec.describe 'Gekanator learning API', type: :request do
|
||||
expect(json['questions'].map { _1['id'] }).to include(existing.id)
|
||||
end
|
||||
|
||||
it 'prioritizes questions the current user has not answered' do
|
||||
sign_in_as admin
|
||||
|
||||
answered = create_post_similarity_question!(
|
||||
text: 'already answered?',
|
||||
priority_weight: 3.0
|
||||
)
|
||||
GekanatorQuestionExample.create!(
|
||||
gekanator_question: answered,
|
||||
post: other_post,
|
||||
user: admin,
|
||||
answer: 'yes',
|
||||
source: 'post_game_extra'
|
||||
)
|
||||
|
||||
unanswered =
|
||||
6.times.map { |index|
|
||||
create_post_similarity_question!(
|
||||
text: "unanswered #{index}?",
|
||||
priority_weight: 0.5
|
||||
)
|
||||
}
|
||||
|
||||
get "/gekanator/games/#{game.id}/extra_questions"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json['questions'].map { _1['id'] }).to match_array(
|
||||
unanswered.map(&:id)
|
||||
)
|
||||
end
|
||||
|
||||
it 'can return questions already asked in the game using snake_case question_id' do
|
||||
sign_in_as admin
|
||||
|
||||
|
||||
新しい課題から参照
ユーザをブロックする