feat: add seedResultRange and organize other seeds

This commit is contained in:
2026-09-20 18:11:09 +03:30
parent f660a6b7a7
commit fbce16ef60
8 changed files with 937 additions and 813 deletions
@@ -0,0 +1,77 @@
import { QuestionRangeRule } from '@/modules/questions/entities/question-range-rule.entity';
import { Question } from '@/modules/questions/entities/question.entity';
import { EntityManager } from 'typeorm';
export async function seedQuestionRangeRules(
manager: EntityManager,
questions: Record<string, Question>,
) {
const rangeRuleRepository = manager.getRepository(QuestionRangeRule);
const { q9, q11 } = questions;
/*
* ---------------------------------------------------------
* QUESTION 9 RANGE RULES
* ---------------------------------------------------------
*
* 1 person => 2
* 2 people => 3
* 3 or more => 5
*/
await rangeRuleRepository.save([
rangeRuleRepository.create({
question: q9,
min: 1,
max: 1,
score: 2,
}),
rangeRuleRepository.create({
question: q9,
min: 2,
max: 2,
score: 3,
}),
rangeRuleRepository.create({
question: q9,
min: 3,
max: 2147483647,
score: 5,
}),
]);
/*
* ---------------------------------------------------------
* QUESTION 11 RANGE RULES
* ---------------------------------------------------------
*
* 1 person => 1
* 2 people => 2
* 3 or more => 3
*/
await rangeRuleRepository.save([
rangeRuleRepository.create({
question: q11,
min: 1,
max: 1,
score: 1,
}),
rangeRuleRepository.create({
question: q11,
min: 2,
max: 2,
score: 2,
}),
rangeRuleRepository.create({
question: q11,
min: 3,
max: 2147483647,
score: 3,
}),
]);
}