Refine city filtering in NPC creation process within AdminService
- Added explicit filtering for city-type regions to ensure only valid cities are processed during NPC creation. - Enhanced logging to provide feedback on the number of cities found and their names, improving traceability in the NPC creation workflow. - Updated comments for clarity on the importance of using city regions exclusively.
This commit is contained in:
@@ -1116,6 +1116,7 @@ class AdminService {
|
||||
} = options;
|
||||
|
||||
// Berechne zuerst die Gesamtanzahl, um den Job richtig zu initialisieren
|
||||
// WICHTIG: Nur Städte (city) verwenden, keine anderen Region-Typen
|
||||
let targetRegions = [];
|
||||
if (regionIds && regionIds.length > 0) {
|
||||
targetRegions = await RegionData.findAll({
|
||||
@@ -1125,7 +1126,8 @@ class AdminService {
|
||||
include: [{
|
||||
model: RegionType,
|
||||
as: 'regionType',
|
||||
where: { labelTr: 'city' }
|
||||
where: { labelTr: 'city' },
|
||||
required: true // INNER JOIN - nur Regionen mit city-Type
|
||||
}]
|
||||
});
|
||||
} else {
|
||||
@@ -1133,11 +1135,22 @@ class AdminService {
|
||||
include: [{
|
||||
model: RegionType,
|
||||
as: 'regionType',
|
||||
where: { labelTr: 'city' }
|
||||
where: { labelTr: 'city' },
|
||||
required: true // INNER JOIN - nur Regionen mit city-Type
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
// Zusätzliche Sicherheit: Filtere explizit nach city-Type
|
||||
targetRegions = targetRegions.filter(region => {
|
||||
return region.regionType && region.regionType.labelTr === 'city';
|
||||
});
|
||||
|
||||
console.log(`[createNPCs] Found ${targetRegions.length} cities (filtered)`);
|
||||
if (targetRegions.length > 0) {
|
||||
console.log(`[createNPCs] City names: ${targetRegions.map(r => r.name).join(', ')}`);
|
||||
}
|
||||
|
||||
if (targetRegions.length === 0) {
|
||||
throw new Error('No cities found');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user