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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user