From 031b180ba50802388d1051da9a6facfde2cd74f4 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 19 Jun 2022 11:34:42 +0300 Subject: [PATCH] Add bios to seed --- app/db/seed.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/db/seed.ts b/app/db/seed.ts index 444b1e9fc..e5d513435 100644 --- a/app/db/seed.ts +++ b/app/db/seed.ts @@ -18,6 +18,7 @@ const basicSeeds = [ adminUser, nzapUser, users, + userBios, lastMonthsVoting, lastMonthSuggestions, thisMonthsSuggestions, @@ -66,6 +67,20 @@ function users() { new Array(500).fill(null).map(fakeUser).forEach(db.users.upsert); } +function userBios() { + for (let id = 3; id < 500; id++) { + if (Math.random() < 0.25) continue; // 75% have bio + + sql.prepare(`UPDATE "User" SET bio = $bio WHERE id = $id`).run({ + id, + bio: faker.lorem.paragraphs( + faker.helpers.arrayElement([1, 1, 1, 2, 3, 4]), + "\n\n" + ), + }); + } +} + function fakeUser() { return { discordAvatar: null, @@ -75,7 +90,6 @@ function fakeUser() { twitch: null, twitter: null, youtubeId: null, - // xxx: add bio }; }