Skip to content

Commit

Permalink
Further simplify skill persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
gausie committed Sep 3, 2024
1 parent ef7b19a commit d798cb1
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/oaf/src/commands/clan/skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,27 @@ export async function parseOldLogs() {

for (const [playerId, { kills, skills }] of participation.entries()) {
const player = await tx.player.findUnique({ where: { playerId } });
const playerName =
player?.playerName ?? (await kolClient.players.fetch(playerId))?.name;

if (!player) {
const playerName = (await kolClient.players.fetch(playerId))?.name;
if (!playerName) continue;
tx.player.create({
data: {
playerId,
playerName,
kills,
skills,
},
});
continue;
}
if (!playerName) continue;

tx.player.update({
await tx.player.upsert({
where: { playerId },
data: {
update: {
kills: {
increment: kills,
},
skills: {
increment: skills,
},
},
create: {
playerId,
playerName,
kills,
skills,
},
});
}
});
Expand Down

0 comments on commit d798cb1

Please sign in to comment.