Refactor seed database user function to improve type consistency and add headline to user profile

This commit is contained in:
MartinBraquet
2026-05-23 19:53:56 +02:00
parent 3e7fc0f008
commit 7970aadf7c
2 changed files with 9 additions and 7 deletions

View File

@@ -3,17 +3,17 @@ import {
CANNABIS_CHOICES,
DIET_CHOICES,
EDUCATION_CHOICES,
LANGUAGE_CHOICES,
MBTI_CHOICES,
POLITICAL_CHOICES,
PSYCHEDELICS_CHOICES,
RACE_CHOICES,
RELATIONSHIP_CHOICES,
RELATIONSHIP_STATUS_CHOICES,
ROMANTIC_CHOICES,
RELIGION_CHOICES,
LANGUAGE_CHOICES,
ROMANTIC_CHOICES,
SUBSTANCE_INTENTION_CHOICES,
SUBSTANCE_PREFERENCE_CHOICES,
MBTI_CHOICES,
} from 'common/choices'
class UserAccountInformationForSeeding {
@@ -52,6 +52,7 @@ class UserAccountInformationForSeeding {
occupation_title = faker.person.jobTitle()
university = faker.company.name()
keywords = faker.lorem.word()
headline = faker.lorem.words({min: 8, max: 16})
cannabis = Object.values(CANNABIS_CHOICES)
psychedelics = Object.values(PSYCHEDELICS_CHOICES)

View File

@@ -20,7 +20,7 @@ import {firebaseSignUp} from './firebaseUtils'
export async function seedDbUser(
userInfo: UserAccountInformationForSeeding,
profileType?: string,
): Promise<Boolean> {
): Promise<boolean> {
const pg = createSupabaseDirectClient()
const userId = userInfo.user_id
const deviceToken = randomString()
@@ -45,14 +45,14 @@ export async function seedDbUser(
}
const numberOfLanguages = faker.number.int({min: 1, max: 3})
let languagesKnown = []
const languagesKnown = []
for (let i = 0; i < numberOfLanguages; i++) {
languagesKnown.push(userInfo.randomElement(userInfo.languages))
}
const keywords = faker.number.int({min: 1, max: 4})
let profileKeywords = []
const profileKeywords = []
for (let i = 0; i < keywords; i++) {
profileKeywords.push(userInfo.keywords)
}
@@ -63,6 +63,8 @@ export async function seedDbUser(
bio: bio,
age: userInfo.age,
gender: userInfo.randomElement(userInfo.gender),
headline: userInfo.headline,
keywords: profileKeywords,
ethnicity: [userInfo.randomElement(userInfo.ethnicity)],
height_in_inches: userInfo.height_in_inches,
pref_gender: [userInfo.randomElement(userInfo.pref_gender)],
@@ -86,7 +88,6 @@ export async function seedDbUser(
diet: [userInfo.randomElement(userInfo.diet)],
education_level: userInfo.randomElement(userInfo.education_level),
languages: languagesKnown,
keywords: profileKeywords,
}
const fullProfile = {