feat(falukant): optimize retrieval of not baptized children by using character IDs
All checks were successful
Deploy to production / deploy (push) Successful in 3m16s

This commit is contained in:
Torsten Schulz (local)
2026-09-17 06:42:27 +02:00
parent 57a0e89156
commit afbfdd8ccc

View File

@@ -5855,24 +5855,14 @@ class FalukantService extends BaseService {
async getNotBaptisedChildren(hashedUserId) {
const falukantUser = await getFalukantUserOrFail(hashedUserId);
const userCharacterIds = (await FalukantCharacter.findAll({
where: { userId: falukantUser.id },
attributes: ['id'],
raw: true,
})).map((character) => character.id);
if (userCharacterIds.length === 0) return [];
const children = await ChildRelation.findAll({
include: [
{
model: FalukantCharacter,
as: 'father',
where: {
userId: falukantUser.id,
},
required: false,
},
{
model: FalukantCharacter,
as: 'mother',
where: {
userId: falukantUser.id,
},
required: false,
},
{
model: FalukantCharacter,
as: 'child',
@@ -5888,6 +5878,10 @@ class FalukantService extends BaseService {
],
where: {
nameSet: false,
[Op.or]: [
{ fatherCharacterId: { [Op.in]: userCharacterIds } },
{ motherCharacterId: { [Op.in]: userCharacterIds } },
],
},
order: [['createdAt', 'DESC']],
});