Refactor debug logging in FalukantService for improved clarity and consistency
- Removed specific debug logs for the carrot product and replaced them with generalized logs for all products, enhancing the readability of the logging output. - Updated console logs to provide clearer information about the processing of cities and the results returned, improving traceability during price calculations. - Ensured that all relevant details are logged consistently, aiding in debugging and performance monitoring across different product types.
This commit is contained in:
@@ -3726,16 +3726,11 @@ class FalukantService extends BaseService {
|
|||||||
|
|
||||||
// Für jede Stadt den Preis berechnen und Branch-Typ bestimmen
|
// Für jede Stadt den Preis berechnen und Branch-Typ bestimmen
|
||||||
const results = [];
|
const results = [];
|
||||||
const isCarrot = productId === 3; // Debug für Karotten
|
console.log(`[getProductPricesInCities] Processing ${cities.length} cities for product ${productId}, knowledgeFactor: ${knowledgeFactor}, product.sellCost: ${product.sellCost}`);
|
||||||
if (isCarrot) {
|
|
||||||
console.log(`[getProductPricesInCities CARROT] productId: ${productId}, currentPrice: ${currentPrice}, currentRegionId: ${currentRegionId}, knowledgeFactor: ${knowledgeFactor}, product.sellCost: ${product.sellCost}, cities: ${cities.length}`);
|
|
||||||
}
|
|
||||||
for (const city of cities) {
|
for (const city of cities) {
|
||||||
// Aktuelle Stadt ausschließen
|
// Aktuelle Stadt ausschließen
|
||||||
if (currentRegionId && city.id === currentRegionId) {
|
if (currentRegionId && city.id === currentRegionId) {
|
||||||
if (isCarrot) {
|
console.log(`[getProductPricesInCities] Skipping current city: ${city.name} (${city.id})`);
|
||||||
console.log(`[getProductPricesInCities CARROT] Skipping current city: ${city.name} (${city.id})`);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3750,9 +3745,7 @@ class FalukantService extends BaseService {
|
|||||||
const max = basePrice;
|
const max = basePrice;
|
||||||
const priceInCity = min + (max - min) * (knowledgeFactor / 100);
|
const priceInCity = min + (max - min) * (knowledgeFactor / 100);
|
||||||
|
|
||||||
if (isCarrot) {
|
console.log(`[getProductPricesInCities] City: ${city.name} (${city.id}), worthPercent: ${worthPercent}, basePrice: ${basePrice}, priceInCity: ${priceInCity}, currentPrice: ${currentPrice}, isBetter: ${priceInCity > currentPrice}`);
|
||||||
console.log(`[getProductPricesInCities CARROT] City: ${city.name} (${city.id}), worthPercent: ${worthPercent}, basePrice: ${basePrice}, priceInCity: ${priceInCity}, currentPrice: ${currentPrice}, isBetter: ${priceInCity > currentPrice}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nur Städte zurückgeben, wo der Preis höher ist
|
// Nur Städte zurückgeben, wo der Preis höher ist
|
||||||
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
||||||
@@ -3769,9 +3762,7 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCarrot) {
|
console.log(`[getProductPricesInCities] Adding ${city.name} to results: price=${priceInCity}, branchType=${branchType}`);
|
||||||
console.log(`[getProductPricesInCities CARROT] Adding ${city.name} to results: price=${priceInCity}, branchType=${branchType}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
results.push({
|
results.push({
|
||||||
regionId: city.id,
|
regionId: city.id,
|
||||||
@@ -3782,9 +3773,7 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCarrot) {
|
console.log(`[getProductPricesInCities] Returning ${results.length} cities with better prices for product ${productId}:`, results.map(r => `${r.regionName} (${r.price.toFixed(2)})`).join(', '));
|
||||||
console.log(`[getProductPricesInCities CARROT] Returning ${results.length} cities with better prices:`, results.map(r => `${r.regionName} (${r.price})`).join(', '));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sortiere nach Preis (höchster zuerst)
|
// Sortiere nach Preis (höchster zuerst)
|
||||||
results.sort((a, b) => b.price - a.price);
|
results.sort((a, b) => b.price - a.price);
|
||||||
|
|||||||
Reference in New Issue
Block a user