Remove debug logging from getProductPricesInCities method in FalukantService
- Eliminated console logs that tracked various parameters and results within the getProductPricesInCities method, streamlining the code and reducing output clutter. - This change aims to enhance code readability and maintain focus on essential functionality while maintaining the integrity of the price calculation process.
This commit is contained in:
@@ -3671,7 +3671,6 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getProductPricesInCities(hashedUserId, productId, currentPrice, currentRegionId = null) {
|
async getProductPricesInCities(hashedUserId, productId, currentPrice, currentRegionId = null) {
|
||||||
console.log(`[getProductPricesInCities] Called: productId=${productId}, currentPrice=${currentPrice}, currentRegionId=${currentRegionId}`);
|
|
||||||
const user = await this.getFalukantUserByHashedId(hashedUserId);
|
const user = await this.getFalukantUserByHashedId(hashedUserId);
|
||||||
const character = await FalukantCharacter.findOne({ where: { userId: user.id } });
|
const character = await FalukantCharacter.findOne({ where: { userId: user.id } });
|
||||||
if (!character) {
|
if (!character) {
|
||||||
@@ -3689,7 +3688,6 @@ class FalukantService extends BaseService {
|
|||||||
where: { characterId: character.id, productId: productId }
|
where: { characterId: character.id, productId: productId }
|
||||||
});
|
});
|
||||||
const knowledgeFactor = knowledge?.knowledge || 0;
|
const knowledgeFactor = knowledge?.knowledge || 0;
|
||||||
console.log(`[getProductPricesInCities] product.sellCost=${product.sellCost}, knowledgeFactor=${knowledgeFactor}`);
|
|
||||||
|
|
||||||
// Alle Städte abrufen
|
// Alle Städte abrufen
|
||||||
const cities = await RegionData.findAll({
|
const cities = await RegionData.findAll({
|
||||||
@@ -3717,7 +3715,6 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
console.log(`[getProductPricesInCities] Found ${cities.length} cities`);
|
|
||||||
|
|
||||||
// TownProductWorth für alle Städte und dieses Produkt abrufen
|
// TownProductWorth für alle Städte und dieses Produkt abrufen
|
||||||
const townWorths = await TownProductWorth.findAll({
|
const townWorths = await TownProductWorth.findAll({
|
||||||
@@ -3725,14 +3722,12 @@ class FalukantService extends BaseService {
|
|||||||
attributes: ['regionId', 'worthPercent']
|
attributes: ['regionId', 'worthPercent']
|
||||||
});
|
});
|
||||||
const worthMap = new Map(townWorths.map(tw => [tw.regionId, tw.worthPercent]));
|
const worthMap = new Map(townWorths.map(tw => [tw.regionId, tw.worthPercent]));
|
||||||
console.log(`[getProductPricesInCities] Found ${townWorths.length} townWorths entries`);
|
|
||||||
|
|
||||||
// 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 = [];
|
||||||
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) {
|
||||||
console.log(`[getProductPricesInCities] Skipping current city: ${city.name} (${city.id})`);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3747,12 +3742,9 @@ class FalukantService extends BaseService {
|
|||||||
const max = basePrice;
|
const max = basePrice;
|
||||||
const priceInCity = min + (max - min) * (knowledgeFactor / 100);
|
const priceInCity = min + (max - min) * (knowledgeFactor / 100);
|
||||||
|
|
||||||
console.log(`[getProductPricesInCities] 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
|
||||||
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
|
// Kleine Toleranz (0.01) für Rundungsfehler bei Gleitkommaberechnungen
|
||||||
const PRICE_TOLERANCE = 0.01;
|
const PRICE_TOLERANCE = 0.01;
|
||||||
console.log(`[getProductPricesInCities] priceInCity=${priceInCity}, currentPrice=${currentPrice}, PRICE_TOLERANCE=${PRICE_TOLERANCE}`);
|
|
||||||
if (priceInCity > currentPrice - PRICE_TOLERANCE) {
|
if (priceInCity > currentPrice - PRICE_TOLERANCE) {
|
||||||
// Branch-Typ bestimmen
|
// Branch-Typ bestimmen
|
||||||
let branchType = null; // null = kein Branch
|
let branchType = null; // null = kein Branch
|
||||||
@@ -3766,7 +3758,6 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[getProductPricesInCities] Adding ${city.name} to results: price=${priceInCity}, branchType=${branchType}`);
|
|
||||||
results.push({
|
results.push({
|
||||||
regionId: city.id,
|
regionId: city.id,
|
||||||
regionName: city.name,
|
regionName: city.name,
|
||||||
@@ -3776,7 +3767,6 @@ class FalukantService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[getProductPricesInCities] Returning ${results.length} cities with better prices`);
|
|
||||||
// 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