From 6db7e648f589d2bbb2d9f4151a79c11bb7fa0c86 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 22 Apr 2016 04:20:59 -0500 Subject: [PATCH] Don't insert new row if the update doesn't succeed because of elo mismatch on loss. --- .../Mineplex.Core/src/mineplex/core/elo/EloRepository.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java index 325c338ec..1c5e749f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/elo/EloRepository.java @@ -33,10 +33,13 @@ public class EloRepository extends MinecraftRepository if (elo > oldElo) updateSucceeded = executeUpdate(UPDATE_ELO_ONLY_IF_MATCH, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", oldElo)) > 0; else + { updateSucceeded = executeUpdate(UPDATE_ELO, new ColumnInt("elo", elo - oldElo), new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType)) > 0; + + if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0) + updateSucceeded = true; + } - if (!updateSucceeded && executeUpdate(INSERT_ELO, new ColumnInt("accountId", accountId), new ColumnInt("gameType", gameType), new ColumnInt("elo", elo)) > 0) - updateSucceeded = true; return updateSucceeded; }