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:
@@ -2885,9 +2885,19 @@ class FalukantService extends BaseService {
|
||||
const timings = {};
|
||||
|
||||
try {
|
||||
// 1. User und Character laden
|
||||
// 1. User und Character laden (optimiert: nur benötigte Felder)
|
||||
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');
|
||||
const character = user.character;
|
||||
if (!character) throw new Error('Character not found for this user');
|
||||
|
||||
Reference in New Issue
Block a user