fix(GRO-395): Add demo pet images to seed data #255
+13
-3
@@ -184,7 +184,7 @@ const dogBreeds = [
|
||||
"Brittany", "English Springer Spaniel", "Maltese", "Bichon Frise",
|
||||
"West Highland White Terrier", "Vizsla", "Chihuahua", "Collie",
|
||||
"Basset Hound", "Newfoundland", "Samoyed", "Australian Shepherd",
|
||||
"Pembroke Welsh Corgi", "French Bulldog", "Weimaraner",
|
||||
"Pembroke Welsh Corgi", "French Bulldog", "Weimaraner", "Puggle",
|
||||
"Mixed Breed", "Mixed Breed", "Mixed Breed",
|
||||
];
|
||||
|
||||
@@ -312,6 +312,14 @@ const demoPetImages = [
|
||||
"/demo-pets/dog-sheepdog-merle-running.png",
|
||||
];
|
||||
|
||||
const puggleImages = [
|
||||
"/demo-pets/dog-puggle-fawn-playful.png",
|
||||
"/demo-pets/dog-puggle-black-sitting.png",
|
||||
"/demo-pets/dog-puggle-cream-groomed.png",
|
||||
"/demo-pets/dog-puggle-tricolor-outdoor.png",
|
||||
"/demo-pets/dog-puggle-fawn-grooming.png",
|
||||
];
|
||||
|
||||
// ── Service definitions ──────────────────────────────────────────────────────
|
||||
// Deterministic service IDs + UNIQUE(name) constraint make seed fully idempotent:
|
||||
// first run inserts, subsequent runs update existing rows via ON CONFLICT (name).
|
||||
@@ -652,6 +660,7 @@ async function seed() {
|
||||
const clientRecords: ClientRecord[] = [];
|
||||
const petRecords: PetRecord[] = [];
|
||||
|
||||
let petIndex = 0; // Track pet count to assign Puggle images to first 250 pets
|
||||
const clientBatchSize = 50;
|
||||
for (let batch = 0; batch < Math.ceil(cfg.clientCount / clientBatchSize); batch++) {
|
||||
const clientBatch: (typeof schema.clients.$inferInsert)[] = [];
|
||||
@@ -683,7 +692,7 @@ async function seed() {
|
||||
const petCount = rand() < 0.5 ? 1 : rand() < 0.7 ? 2 : 3;
|
||||
for (let p = 0; p < petCount; p++) {
|
||||
const petId = uuid();
|
||||
const breed = pick(dogBreeds);
|
||||
const breed = petIndex < 250 ? "Puggle" : pick(dogBreeds);
|
||||
const dob = new Date(now);
|
||||
dob.setFullYear(dob.getFullYear() - randInt(1, 14));
|
||||
dob.setMonth(randInt(0, 11));
|
||||
@@ -702,10 +711,11 @@ async function seed() {
|
||||
shampooPreference: pick(shampoos),
|
||||
specialCareNotes: rand() < 0.1 ? "Vet clearance required before grooming" : null,
|
||||
customFields: {},
|
||||
image: pick(demoPetImages),
|
||||
image: petIndex < 250 ? pick(puggleImages) : pick(demoPetImages),
|
||||
});
|
||||
|
||||
petRecords.push({ id: petId, clientId });
|
||||
petIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user