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, ) { 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, }), ]); }