mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 14:51:13 -05:00
feat: Add debug logging for company generation
This commit is contained in:
@@ -78,6 +78,12 @@ export function TestDataGenerator() {
|
|||||||
setResults(null);
|
setResults(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log('=== TEST DATA GENERATOR DEBUG ===');
|
||||||
|
console.log('Selected entity types:', selectedEntityTypes);
|
||||||
|
console.log('Preset:', preset);
|
||||||
|
console.log('Field density:', fieldDensity);
|
||||||
|
console.log('===================================');
|
||||||
|
|
||||||
const { data, error } = await supabase.functions.invoke('seed-test-data', {
|
const { data, error } = await supabase.functions.invoke('seed-test-data', {
|
||||||
body: {
|
body: {
|
||||||
preset,
|
preset,
|
||||||
|
|||||||
@@ -174,6 +174,13 @@ Deno.serve(async (req) => {
|
|||||||
includeExpiredLocks = false
|
includeExpiredLocks = false
|
||||||
}: SeedOptions = await req.json();
|
}: SeedOptions = await req.json();
|
||||||
|
|
||||||
|
console.info('=== SEED DATA GENERATION DEBUG ===');
|
||||||
|
console.info('Received entityTypes:', JSON.stringify(entityTypes));
|
||||||
|
console.info('entityTypes is array:', Array.isArray(entityTypes));
|
||||||
|
console.info('entityTypes length:', entityTypes?.length);
|
||||||
|
console.info('Preset:', preset);
|
||||||
|
console.info('===================================');
|
||||||
|
|
||||||
const plan = PRESETS[preset];
|
const plan = PRESETS[preset];
|
||||||
if (!plan) {
|
if (!plan) {
|
||||||
return new Response(JSON.stringify({ error: 'Invalid preset' }), {
|
return new Response(JSON.stringify({ error: 'Invalid preset' }), {
|
||||||
@@ -346,11 +353,21 @@ Deno.serve(async (req) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create companies FIRST so parks can reference operators/owners
|
// Create companies FIRST so parks can reference operators/owners
|
||||||
|
console.info('=== COMPANY GENERATION CHECK ===');
|
||||||
|
console.info('Entity types array:', JSON.stringify(entityTypes));
|
||||||
|
console.info('Plan calls for companies:', plan.companies);
|
||||||
|
|
||||||
const companyTypes = ['manufacturer', 'operator', 'designer', 'property_owner'];
|
const companyTypes = ['manufacturer', 'operator', 'designer', 'property_owner'];
|
||||||
for (const compType of companyTypes) {
|
for (const compType of companyTypes) {
|
||||||
if (entityTypes.includes(pluralizeCompanyType(compType))) {
|
const pluralType = pluralizeCompanyType(compType);
|
||||||
|
const shouldGenerate = entityTypes.includes(pluralType);
|
||||||
|
console.info(`Checking ${compType} → ${pluralType}: ${shouldGenerate}`);
|
||||||
|
|
||||||
|
if (shouldGenerate) {
|
||||||
const count = Math.floor(plan.companies / 4);
|
const count = Math.floor(plan.companies / 4);
|
||||||
|
console.info(`✓ Generating ${count} companies of type ${compType}`);
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
|
console.info(` Creating company ${i + 1}/${count} (type: ${compType})`);
|
||||||
const level = getPopulationLevel(fieldDensity, i);
|
const level = getPopulationLevel(fieldDensity, i);
|
||||||
const companyData: any = {
|
const companyData: any = {
|
||||||
name: `Test ${compType.replace('_', ' ')} ${i + 1}`,
|
name: `Test ${compType.replace('_', ' ')} ${i + 1}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user