Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros committed Dec 19, 2024
1 parent 89721b0 commit 32b70f3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libs/model/src/user/Xp.projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ async function getUserId(payload: { address_id: number }) {

async function getUserIdByAddress(payload: {
referrer_address?: string;
}): Promise<number | undefined | null> {
}): Promise<number | undefined> {
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!;
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 32b70f3

Please sign in to comment.