Refactor and remove debug logging in FalukantService and RevenueSection for cleaner code
- Eliminated console logs in the getProductPricesInCities method of FalukantService to streamline the price calculation process and reduce clutter in the output. - Removed unnecessary debug logs in RevenueSection related to loading product prices, enhancing performance and focusing on essential functionality. - Improved overall code readability by reducing logging noise while maintaining necessary functionality.
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 with 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) {
|
||||||
@@ -3726,11 +3725,9 @@ 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 = [];
|
||||||
console.log(`[getProductPricesInCities] Processing ${cities.length} cities for product ${productId}, knowledgeFactor: ${knowledgeFactor}, product.sellCost: ${product.sellCost}`);
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3745,8 +3742,6 @@ 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
|
||||||
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
||||||
if (priceInCity > currentPrice) {
|
if (priceInCity > currentPrice) {
|
||||||
@@ -3762,8 +3757,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,
|
||||||
@@ -3772,8 +3765,6 @@ class FalukantService extends BaseService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`[getProductPricesInCities] Returning ${results.length} cities with better prices for product ${productId}:`, results.map(r => `${r.regionName} (${r.price.toFixed(2)})`).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);
|
||||||
|
|||||||
@@ -105,16 +105,13 @@
|
|||||||
},
|
},
|
||||||
async loadPricesForAllProducts() {
|
async loadPricesForAllProducts() {
|
||||||
if (this.currentRegionId === null || this.currentRegionId === undefined) {
|
if (this.currentRegionId === null || this.currentRegionId === undefined) {
|
||||||
console.log(`[RevenueSection] Skipping loadPricesForAllProducts - currentRegionId is null/undefined`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(`[RevenueSection] loadPricesForAllProducts called, products: ${this.products.length}, currentRegionId: ${this.currentRegionId}`);
|
|
||||||
for (const product of this.products) {
|
for (const product of this.products) {
|
||||||
if (this.loadingPrices.has(product.id)) continue;
|
if (this.loadingPrices.has(product.id)) continue;
|
||||||
this.loadingPrices.add(product.id);
|
this.loadingPrices.add(product.id);
|
||||||
try {
|
try {
|
||||||
const currentPrice = parseFloat(this.calculateProductRevenue(product).absolute);
|
const currentPrice = parseFloat(this.calculateProductRevenue(product).absolute);
|
||||||
console.log(`[RevenueSection] Loading prices for product ${product.id} (${product.labelTr}), currentPrice: ${currentPrice}, currentRegionId: ${this.currentRegionId}`);
|
|
||||||
const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', {
|
const { data } = await apiClient.get('/api/falukant/products/prices-in-cities', {
|
||||||
params: {
|
params: {
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
@@ -122,7 +119,6 @@
|
|||||||
currentRegionId: this.currentRegionId
|
currentRegionId: this.currentRegionId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(`[RevenueSection] Received better prices for product ${product.id}:`, data);
|
|
||||||
this.$set(product, 'betterPrices', data || []);
|
this.$set(product, 'betterPrices', data || []);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error loading prices for product ${product.id}:`, error);
|
console.error(`Error loading prices for product ${product.id}:`, error);
|
||||||
|
|||||||
Reference in New Issue
Block a user