Skip to content

Commit

Permalink
Merge pull request #69 from x-team/develop
Browse files Browse the repository at this point in the history
Merge Hotfix
  • Loading branch information
ccmoralesj authored Mar 17, 2023
2 parents d420e5e + 8b525ed commit cb60747
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/models/TowerRoundAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,29 @@ export async function findAllActionsByRound(roundId: number, transaction: Transa
});
}

interface OptionalWhereParams {
_towerRaiderId?: number;
_towerFloorBattlefieldEnemyId?: number;
_towerRoundId: number;
}

export async function findRoundAction(
{ raiderId = null, enemyId = null, roundId }: RoundActionKey,
transaction?: Transaction
) {
let mutableWhereQuery: OptionalWhereParams = {
_towerRoundId: roundId,
};
if (raiderId) {
mutableWhereQuery['_towerRaiderId'] = raiderId;
}

if (enemyId) {
mutableWhereQuery['_towerFloorBattlefieldEnemyId'] = enemyId;
}

return TowerRoundAction.findOne({
where: {
_towerRaiderId: raiderId ?? undefined,
_towerFloorBattlefieldEnemyId: enemyId ?? undefined,
_towerRoundId: roundId ?? undefined,
},
where: mutableWhereQuery as WhereOptions<TowerRoundActionAttributes>,
transaction,
});
}
Expand Down

0 comments on commit cb60747

Please sign in to comment.