mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-14 18:05:55 +08:00
[questions][fix] fix seed questions script (#467)
This commit is contained in:
@ -83,7 +83,6 @@ const CODING_QUESTIONS: Array<QuestionCreateData> = CODING_QUESTION_CONTENT.map(
|
|||||||
userId: null,
|
userId: null,
|
||||||
encounters: {
|
encounters: {
|
||||||
create: {
|
create: {
|
||||||
location: 'Singapore',
|
|
||||||
role: selectRandomRole(),
|
role: selectRandomRole(),
|
||||||
seenAt: generateRandomDate(),
|
seenAt: generateRandomDate(),
|
||||||
},
|
},
|
||||||
@ -98,7 +97,6 @@ const BEHAVIORAL_QUESTIONS: Array<QuestionCreateData> =
|
|||||||
userId: null,
|
userId: null,
|
||||||
encounters: {
|
encounters: {
|
||||||
create: {
|
create: {
|
||||||
location: 'Singapore',
|
|
||||||
role: selectRandomRole(),
|
role: selectRandomRole(),
|
||||||
seenAt: generateRandomDate(),
|
seenAt: generateRandomDate(),
|
||||||
},
|
},
|
||||||
@ -120,6 +118,15 @@ async function main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const firstCity = await prisma.city.findFirst({
|
||||||
|
include: {
|
||||||
|
state: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!firstCity) {
|
||||||
|
throw new Error('No city found. Please seed db with some cities first.');
|
||||||
|
}
|
||||||
|
|
||||||
// Generate random answers to the questions
|
// Generate random answers to the questions
|
||||||
const users = await prisma.user.findMany();
|
const users = await prisma.user.findMany();
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
@ -138,6 +145,9 @@ async function main() {
|
|||||||
create: {
|
create: {
|
||||||
...question.encounters!.create,
|
...question.encounters!.create,
|
||||||
companyId: firstCompany.id,
|
companyId: firstCompany.id,
|
||||||
|
stateId: firstCity.stateId,
|
||||||
|
cityId: firstCity.id,
|
||||||
|
countryId: firstCity.state.countryId,
|
||||||
} as any,
|
} as any,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user