Optimize user and character loading in FalukantService by querying only necessary fields. This change enhances performance and reduces data overhead during retrieval.

This commit is contained in:
Torsten Schulz (local)
2026-01-12 11:35:38 +01:00
parent 479f222b54
commit d75fe18e6a

View File

@@ -2885,9 +2885,19 @@ class FalukantService extends BaseService {
const timings = {}; const timings = {};
try { try {
// 1. User und Character laden // 1. User und Character laden (optimiert: nur benötigte Felder)
const step1Start = Date.now(); const step1Start = Date.now();
const user = await this.getFalukantUserByHashedId(hashedUserId); const user = await FalukantUser.findOne({
include: [
{ model: User, as: 'user', attributes: ['hashedId'], where: { hashedId: hashedUserId } },
{
model: FalukantCharacter,
as: 'character',
attributes: ['id', 'birthdate', 'gender', 'regionId', 'titleOfNobility'],
required: true
}
]
});
if (!user) throw new Error('User not found'); if (!user) throw new Error('User not found');
const character = user.character; const character = user.character;
if (!character) throw new Error('Character not found for this user'); if (!character) throw new Error('Character not found for this user');