mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-20 01:25:37 +01:00
[#943] Removed unnecessary Server UUID column from some queries
This commit is contained in:
parent
a235bda099
commit
423d9c88a0
@ -40,15 +40,14 @@ import static com.djrapitops.plan.db.sql.parsing.Sql.*;
|
|||||||
public class WorldTimesQueries {
|
public class WorldTimesQueries {
|
||||||
|
|
||||||
private static String worldColumn = "world";
|
private static String worldColumn = "world";
|
||||||
|
private static final String SELECT_WORLD_TIMES_JOIN_WORLD_NAME = WorldTable.TABLE_NAME + "." + WorldTable.NAME + " as " + worldColumn +
|
||||||
|
FROM + WorldTimesTable.TABLE_NAME +
|
||||||
|
INNER_JOIN + WorldTable.TABLE_NAME + " on " + WorldTable.TABLE_NAME + "." + WorldTable.ID + "=" + WorldTimesTable.WORLD_ID;
|
||||||
private static final String SELECT_WORLD_TIMES_STATEMENT_START = SELECT +
|
private static final String SELECT_WORLD_TIMES_STATEMENT_START = SELECT +
|
||||||
"SUM(" + WorldTimesTable.SURVIVAL + ") as survival, " +
|
"SUM(" + WorldTimesTable.SURVIVAL + ") as survival, " +
|
||||||
"SUM(" + WorldTimesTable.CREATIVE + ") as creative, " +
|
"SUM(" + WorldTimesTable.CREATIVE + ") as creative, " +
|
||||||
"SUM(" + WorldTimesTable.ADVENTURE + ") as adventure, " +
|
"SUM(" + WorldTimesTable.ADVENTURE + ") as adventure, " +
|
||||||
"SUM(" + WorldTimesTable.SPECTATOR + ") as spectator, " +
|
"SUM(" + WorldTimesTable.SPECTATOR + ") as spectator, ";
|
||||||
WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + ", " +
|
|
||||||
WorldTable.TABLE_NAME + "." + WorldTable.NAME + " as " + worldColumn +
|
|
||||||
FROM + WorldTimesTable.TABLE_NAME +
|
|
||||||
" INNER JOIN " + WorldTable.TABLE_NAME + " on " + WorldTable.TABLE_NAME + "." + WorldTable.ID + "=" + WorldTimesTable.WORLD_ID;
|
|
||||||
|
|
||||||
private WorldTimesQueries() {
|
private WorldTimesQueries() {
|
||||||
/* Static method class */
|
/* Static method class */
|
||||||
@ -62,6 +61,7 @@ public class WorldTimesQueries {
|
|||||||
*/
|
*/
|
||||||
public static Query<WorldTimes> fetchServerTotalWorldTimes(UUID serverUUID) {
|
public static Query<WorldTimes> fetchServerTotalWorldTimes(UUID serverUUID) {
|
||||||
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
||||||
|
SELECT_WORLD_TIMES_JOIN_WORLD_NAME +
|
||||||
WHERE + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + "=?" +
|
WHERE + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + "=?" +
|
||||||
GROUP_BY + worldColumn;
|
GROUP_BY + worldColumn;
|
||||||
|
|
||||||
@ -96,6 +96,7 @@ public class WorldTimesQueries {
|
|||||||
*/
|
*/
|
||||||
public static Query<WorldTimes> fetchPlayerTotalWorldTimes(UUID playerUUID) {
|
public static Query<WorldTimes> fetchPlayerTotalWorldTimes(UUID playerUUID) {
|
||||||
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
||||||
|
SELECT_WORLD_TIMES_JOIN_WORLD_NAME +
|
||||||
WHERE + WorldTimesTable.USER_UUID + "=?" +
|
WHERE + WorldTimesTable.USER_UUID + "=?" +
|
||||||
GROUP_BY + worldColumn;
|
GROUP_BY + worldColumn;
|
||||||
|
|
||||||
@ -130,6 +131,8 @@ public class WorldTimesQueries {
|
|||||||
*/
|
*/
|
||||||
public static Query<Map<UUID, WorldTimes>> fetchPlayerWorldTimesOnServers(UUID playerUUID) {
|
public static Query<Map<UUID, WorldTimes>> fetchPlayerWorldTimesOnServers(UUID playerUUID) {
|
||||||
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
String sql = SELECT_WORLD_TIMES_STATEMENT_START +
|
||||||
|
WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID + ", " +
|
||||||
|
SELECT_WORLD_TIMES_JOIN_WORLD_NAME +
|
||||||
WHERE + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.USER_UUID + "=?" +
|
WHERE + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.USER_UUID + "=?" +
|
||||||
GROUP_BY + worldColumn + ", " + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID;
|
GROUP_BY + worldColumn + ", " + WorldTimesTable.TABLE_NAME + "." + WorldTimesTable.SERVER_UUID;
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ public abstract class CommonDBTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveSessionsWorldTimes() {
|
public void worldTimesAreSavedWithSession() {
|
||||||
saveTwoWorlds();
|
saveTwoWorlds();
|
||||||
saveUserOne();
|
saveUserOne();
|
||||||
|
|
||||||
@ -733,21 +733,21 @@ public abstract class CommonDBTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUserWorldTimes() {
|
public void playersWorldTimesMatchTotal() {
|
||||||
testSaveSessionsWorldTimes();
|
worldTimesAreSavedWithSession();
|
||||||
WorldTimes worldTimesOfUser = db.query(WorldTimesQueries.fetchPlayerTotalWorldTimes(playerUUID));
|
WorldTimes worldTimesOfUser = db.query(WorldTimesQueries.fetchPlayerTotalWorldTimes(playerUUID));
|
||||||
assertEquals(createWorldTimes(), worldTimesOfUser);
|
assertEquals(createWorldTimes(), worldTimesOfUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServerWorldTimes() {
|
public void serverWorldTimesMatchTotal() {
|
||||||
testSaveSessionsWorldTimes();
|
worldTimesAreSavedWithSession();
|
||||||
WorldTimes worldTimesOfServer = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
|
WorldTimes worldTimesOfServer = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
|
||||||
assertEquals(createWorldTimes(), worldTimesOfServer);
|
assertEquals(createWorldTimes(), worldTimesOfServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetServerWorldTimesNoSessions() {
|
public void emptyServerWorldTimesIsEmpty() {
|
||||||
WorldTimes worldTimesOfServer = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
|
WorldTimes worldTimesOfServer = db.query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID));
|
||||||
assertEquals(new WorldTimes(new HashMap<>()), worldTimesOfServer);
|
assertEquals(new WorldTimes(new HashMap<>()), worldTimesOfServer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user