-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved group by before order by - Fixed off by one error in the offset Affects issues: - Fixed #2206
- Loading branch information
Showing
5 changed files
with
109 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...mmon/src/test/java/com/djrapitops/plan/storage/database/queries/QueriesTestAggregate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This file is part of Player Analytics (Plan). | ||
* | ||
* Plan is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License v3 as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Plan is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Plan. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.djrapitops.plan.storage.database.queries; | ||
|
||
import com.djrapitops.plan.storage.database.queries.analysis.TopListQueriesTest; | ||
|
||
public interface QueriesTestAggregate extends | ||
ActivityIndexQueriesTest, | ||
DatabaseBackupTest, | ||
ExtensionsDatabaseTest, | ||
GeolocationQueriesTest, | ||
NicknameQueriesTest, | ||
PingQueriesTest, | ||
ServerQueriesTest, | ||
SessionQueriesTest, | ||
TopListQueriesTest, | ||
TPSQueriesTest, | ||
UserInfoQueriesTest, | ||
WebUserQueriesTest { | ||
/* Collects all query tests together so its easier to implement database tests */ | ||
} |
63 changes: 63 additions & 0 deletions
63
...c/test/java/com/djrapitops/plan/storage/database/queries/analysis/TopListQueriesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This file is part of Player Analytics (Plan). | ||
* | ||
* Plan is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License v3 as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Plan is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Plan. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.djrapitops.plan.storage.database.queries.analysis; | ||
|
||
import com.djrapitops.plan.gathering.domain.FinishedSession; | ||
import com.djrapitops.plan.storage.database.DatabaseTestPreparer; | ||
import com.djrapitops.plan.storage.database.queries.DataStoreQueries; | ||
import com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction; | ||
import com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction; | ||
import org.junit.jupiter.api.Test; | ||
import utilities.RandomData; | ||
import utilities.TestConstants; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public interface TopListQueriesTest extends DatabaseTestPreparer { | ||
|
||
private void storeSessionForTopListQueries() { | ||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0])); | ||
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1])); | ||
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, | ||
TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME)); | ||
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, | ||
TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME)); | ||
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID); | ||
execute(DataStoreQueries.storeSession(session)); | ||
} | ||
|
||
@Test | ||
default void topActivePlaytimeListQueryReturnsSinglePlayer() { | ||
storeSessionForTopListQueries(); | ||
|
||
String expected = TestConstants.PLAYER_ONE_NAME; | ||
String result = db().query(TopListQueries.fetchNthTop10ActivePlaytimePlayerOn(serverUUID(), 1, 0, System.currentTimeMillis())) | ||
.orElseThrow(AssertionError::new); | ||
assertEquals(expected, result); | ||
} | ||
|
||
@Test | ||
default void topPlaytimeListQueryReturnsSinglePlayer() { | ||
storeSessionForTopListQueries(); | ||
|
||
String expected = TestConstants.PLAYER_ONE_NAME; | ||
String result = db().query(TopListQueries.fetchNthTop10ActivePlaytimePlayerOn(serverUUID(), 1, 0, System.currentTimeMillis())) | ||
.orElseThrow(AssertionError::new); | ||
assertEquals(expected, result); | ||
} | ||
|
||
} |