From fa1cd00c227a3990406d069b613bdef077102d55 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 02:56:00 -0400 Subject: [PATCH] Tidy up leaderboard repository class a bit --- .../src/mineplex/core/leaderboard/LeaderboardRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 6650af665..783f561ca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -20,8 +20,10 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; + private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date, season), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;";