diff --git a/packages/models/scripts/seed.ts b/packages/models/scripts/seed.ts index f691406a6..aa660df3d 100644 --- a/packages/models/scripts/seed.ts +++ b/packages/models/scripts/seed.ts @@ -17,12 +17,12 @@ import { withdrawMethods, invoices, hashPassword, + topics, } from "@litespace/models"; import { ICall, IInterview, ILesson, - IRating, IUser, IWithdrawMethod, } from "@litespace/types"; @@ -256,6 +256,29 @@ async function main(): Promise { ); }); + // seeding topics data + await knex.transaction(async (tx) => { + stdout.info(`Inserting 50 random topics in the database.`); + + const mockTopics = faker.lorem.words(50).split(" "); + for (let i = 0; i < mockTopics.length; i++) { + if (mockTopics.slice(i+1, mockTopics.length).includes(mockTopics[i])) { + mockTopics[i] = "_" + mockTopics[i] + "_"; + } + } + + return await Promise.all( + mockTopics.map(async (topic: string) => { + await topics.create({ + name: { + ar: topic, + en: topic, + } + }, tx); + }) + ); + }); + const rule = await rules.create({ userId: tutorManager.id, frequency: IRule.Frequency.Daily,