From 32b70f3a497af559775719a56add301c73dd7749 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Thu, 19 Dec 2024 23:25:59 +0100 Subject: [PATCH] simplify --- libs/model/src/user/Xp.projection.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/model/src/user/Xp.projection.ts b/libs/model/src/user/Xp.projection.ts index 332b401ad3b..33c4e9038a2 100644 --- a/libs/model/src/user/Xp.projection.ts +++ b/libs/model/src/user/Xp.projection.ts @@ -21,13 +21,13 @@ async function getUserId(payload: { address_id: number }) { async function getUserIdByAddress(payload: { referrer_address?: string; -}): Promise { +}): Promise { if (payload.referrer_address) { const referrer_user = await models.Address.findOne({ where: { address: payload.referrer_address }, attributes: ['user_id'], }); - if (referrer_user) return referrer_user.user_id; + if (referrer_user) return referrer_user.user_id!; } } @@ -86,9 +86,9 @@ async function recordXpsForQuest( creator_address?: string, ) { await sequelize.transaction(async (transaction) => { - const creator_user_id = - (await getUserIdByAddress({ referrer_address: creator_address })) || - undefined; + const creator_user_id = await getUserIdByAddress({ + referrer_address: creator_address, + }); for (const action_meta of action_metas) { if (!action_meta) continue; @@ -174,9 +174,9 @@ async function recordXpsForEvent( creator_reward_weight?: number, // referrer reward weight ) { await sequelize.transaction(async (transaction) => { - const creator_user_id = - (await getUserIdByAddress({ referrer_address: creator_address })) || - undefined; + const creator_user_id = await getUserIdByAddress({ + referrer_address: creator_address, + }); // get logged actions for this user and event const log = await models.XpLog.findAll({