From 015d1ae95b1703e7a5517c0eb1c96e7270af5df9 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 12 Jan 2026 12:02:46 +0100 Subject: [PATCH] Refactor getGiftCost method in FalukantService for improved performance - Changed getGiftCost from an asynchronous to a synchronous method, eliminating unnecessary await for better efficiency. - Updated comments for clarity regarding the synchronous nature of gift cost calculation. - Adjusted related code to reflect the synchronous execution, enhancing overall performance in gift cost retrieval. --- backend/services/falukantService.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index 8a2088a..27d8f60 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -3666,7 +3666,7 @@ class FalukantService extends BaseService { ]); timings.step5_load_gifts_and_title = Date.now() - step5Start; - // 6) Kosten berechnen (getGiftCost ist synchron, kein await nötig) + // 6) Kosten berechnen (getGiftCost ist synchron) const step6Start = Date.now(); const result = gifts.map(gift => ({ id: gift.id, @@ -3786,7 +3786,7 @@ class FalukantService extends BaseService { if (!gift) { throw new Error('notFound'); } - const cost = await this.getGiftCost( + const cost = this.getGiftCost( gift.value, user.character.nobleTitle.id, lowestTitle.id @@ -3842,7 +3842,7 @@ class FalukantService extends BaseService { } } - async getGiftCost(value, titleOfNobility, lowestTitleOfNobility) { + getGiftCost(value, titleOfNobility, lowestTitleOfNobility) { const titleLevel = titleOfNobility - lowestTitleOfNobility + 1; return Math.round(value * Math.pow(1 + titleLevel * 0.3, 1.3) * 100) / 100; }