diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/SessionQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/SessionQueries.java index b14e50b2d..b7af1734f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/SessionQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/objects/SessionQueries.java @@ -746,12 +746,12 @@ public class SessionQueries { String sql = SELECT + "SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime," + "s." + ServerTable.SERVER_ID + ',' + - ServerTable.NAME + + "s." + ServerTable.NAME + FROM + SessionsTable.TABLE_NAME + INNER_JOIN + ServerTable.TABLE_NAME + " s on s." + ServerTable.SERVER_UUID + '=' + SessionsTable.TABLE_NAME + '.' + SessionsTable.SERVER_UUID + WHERE + SessionsTable.SESSION_END + ">=?" + AND + SessionsTable.SESSION_START + "<=?" + - GROUP_BY + ServerTable.NAME; + GROUP_BY + "s." + ServerTable.SERVER_ID; return new QueryStatement>(sql, 100) { @Override public void prepare(PreparedStatement statement) throws SQLException { diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTestPreparer.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTestPreparer.java index d9c68d345..41f7f9465 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTestPreparer.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/DatabaseTestPreparer.java @@ -25,6 +25,7 @@ import com.djrapitops.plan.storage.database.transactions.Transaction; import utilities.TestConstants; import java.util.UUID; +import java.util.concurrent.ExecutionException; public interface DatabaseTestPreparer { @@ -57,17 +58,25 @@ public interface DatabaseTestPreparer { } default void execute(Executable executable) { - db().executeTransaction(new Transaction() { - @Override - protected void performOperations() { - execute(executable); - } - }); + try { + db().executeTransaction(new Transaction() { + @Override + protected void performOperations() { + execute(executable); + } + }).get(); + } catch (InterruptedException | ExecutionException e) { + throw new AssertionError(e); + } } default void executeTransactions(Transaction... transactions) { for (Transaction transaction : transactions) { - db().executeTransaction(transaction); + try { + db().executeTransaction(transaction).get(); + } catch (InterruptedException | ExecutionException e) { + throw new AssertionError(e); + } } } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java index 1616482f3..054020384 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/SessionQueriesTest.java @@ -328,11 +328,14 @@ public interface SessionQueriesTest extends DatabaseTestPreparer { @Test default void serverPreferencePieValuesAreCorrect() { prepareForSessionSave(); + List server1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID); + server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session))); + UUID serverTwoUuid = TestConstants.SERVER_TWO_UUID; executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, ""))); - List server1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID); + db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[0])); + db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[1])); List server2Sessions = RandomData.randomSessions(serverTwoUuid, worlds, playerUUID, player2UUID); - server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session))); server2Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session))); Map expected = Maps.builder(String.class, Long.class)