Skip to content

Commit

Permalink
Merge pull request #222 from loathers/fix-clan-issues
Browse files Browse the repository at this point in the history
don't break the loop upon finding a new player
  • Loading branch information
gausie authored Sep 3, 2024
2 parents e462b54 + 7c3c732 commit ec4fa33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Force oaf to recalculate all raid stats.
TRUNCATE TABLE "Raid";
UPDATE "Player" SET "kills" = 0, "skills" = 0;
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 @@ 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) return;
tx.player.create({
data: {
playerId,
playerName,
kills,
skills,
},
});
return;
}
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 ec4fa33

Please sign in to comment.