mirror of
https://github.com/Oak-and-Sprout/sprout-track.git
synced 2026-05-08 08:00:42 -05:00
updates to add app config to generating the test data
This commit is contained in:
@@ -294,6 +294,7 @@ FAMILY_COUNT=3 DAYS_COUNT=14 CLEAR_DATA=true ./Scripts/generate-test-data.sh
|
||||
|
||||
The script creates realistic test data including:
|
||||
|
||||
- **App Configuration**: Global settings (domain: demo.sprout-track.com, HTTPS enabled)
|
||||
- **Families**: With unique slugs and names
|
||||
- **Caretakers**: Parents, grandparents, nannies, etc. (2-4 per family)
|
||||
- **Babies**: With realistic birth dates (1-2 per family)
|
||||
|
||||
@@ -227,7 +227,7 @@ async function clearExistingData() {
|
||||
const models = [
|
||||
'familyMember', 'sleepLog', 'feedLog', 'diaperLog', 'moodLog', 'note',
|
||||
'milestone', 'pumpLog', 'playLog', 'bathLog', 'measurement', 'medicineLog',
|
||||
'medicine', 'calendarEvent', 'contact', 'baby', 'caretaker', 'settings', 'family'
|
||||
'medicine', 'calendarEvent', 'contact', 'baby', 'caretaker', 'settings', 'family', 'appConfig'
|
||||
];
|
||||
|
||||
for (const model of models) {
|
||||
@@ -240,6 +240,23 @@ async function clearExistingData() {
|
||||
}
|
||||
}
|
||||
|
||||
// Generate app configuration
|
||||
async function generateAppConfig() {
|
||||
console.log('Generating app configuration...');
|
||||
|
||||
const appConfig = await prisma.appConfig.create({
|
||||
data: {
|
||||
id: randomUUID(),
|
||||
adminPass: 'admin', // Plain text - will be encrypted by the API when used
|
||||
rootDomain: 'demo.sprout-track.com',
|
||||
enableHttps: true
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`Created app config with domain: ${appConfig.rootDomain}`);
|
||||
return appConfig;
|
||||
}
|
||||
|
||||
// Generate a family
|
||||
async function generateFamily() {
|
||||
const lastName = randomChoice(lastNames);
|
||||
@@ -673,6 +690,9 @@ async function generateTestData() {
|
||||
await clearExistingData();
|
||||
}
|
||||
|
||||
// Generate app configuration
|
||||
await generateAppConfig();
|
||||
|
||||
// Generate cutoff time (between 15 minutes and 3 hours ago)
|
||||
const cutoffTime = generateCutoffTime();
|
||||
const endDate = new Date(cutoffTime);
|
||||
@@ -759,6 +779,7 @@ async function generateTestData() {
|
||||
|
||||
console.log(`\nTest data generation completed successfully!`);
|
||||
console.log(`Generated:`);
|
||||
console.log(`- 1 app configuration (domain: demo.sprout-track.com, HTTPS: enabled)`);
|
||||
console.log(`- ${familyCount} families`);
|
||||
console.log(`- ${totalCaretakers} caretakers`);
|
||||
console.log(`- ${totalBabies} babies`);
|
||||
|
||||
Reference in New Issue
Block a user