Don't insert new row if the update doesn't succeed because of elo mismatch on loss.

This commit is contained in:
Jonathan Williams 2016-04-22 04:20:59 -05:00
parent 7b18efa7b0
commit 6db7e648f5

View File

@ -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;
}