feat(falukant): optimize retrieval of not baptized children by using character IDs
All checks were successful
Deploy to production / deploy (push) Successful in 3m16s
All checks were successful
Deploy to production / deploy (push) Successful in 3m16s
This commit is contained in:
@@ -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']],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user