Skip to content

Commit cb60747

Browse files
authored
Merge pull request #69 from x-team/develop
Merge Hotfix
2 parents d420e5e + 8b525ed commit cb60747

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/models/TowerRoundAction.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,29 @@ export async function findAllActionsByRound(roundId: number, transaction: Transa
248248
});
249249
}
250250

251+
interface OptionalWhereParams {
252+
_towerRaiderId?: number;
253+
_towerFloorBattlefieldEnemyId?: number;
254+
_towerRoundId: number;
255+
}
256+
251257
export async function findRoundAction(
252258
{ raiderId = null, enemyId = null, roundId }: RoundActionKey,
253259
transaction?: Transaction
254260
) {
261+
let mutableWhereQuery: OptionalWhereParams = {
262+
_towerRoundId: roundId,
263+
};
264+
if (raiderId) {
265+
mutableWhereQuery['_towerRaiderId'] = raiderId;
266+
}
267+
268+
if (enemyId) {
269+
mutableWhereQuery['_towerFloorBattlefieldEnemyId'] = enemyId;
270+
}
271+
255272
return TowerRoundAction.findOne({
256-
where: {
257-
_towerRaiderId: raiderId ?? undefined,
258-
_towerFloorBattlefieldEnemyId: enemyId ?? undefined,
259-
_towerRoundId: roundId ?? undefined,
260-
},
273+
where: mutableWhereQuery as WhereOptions<TowerRoundActionAttributes>,
261274
transaction,
262275
});
263276
}

0 commit comments

Comments
 (0)