Search in sources :

Example 1 with StoreSessionTransaction

use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.

the class ActivityIndexQueriesTest method storeSessions.

default void storeSessions(Predicate<FinishedSession> save) {
    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));
    for (String world : worlds) {
        db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), world));
    }
    for (FinishedSession session : RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID)) {
        if (save.test(session))
            db().executeTransaction(new StoreSessionTransaction(session));
    }
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)

Example 2 with StoreSessionTransaction

use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.

the class JoinAddressQueriesTest method joinAddressCanBeUnknown.

@Test
default void joinAddressCanBeUnknown() {
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
    db().executeTransaction(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME));
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    session.getExtraData().remove(JoinAddress.class);
    db().executeTransaction(new StoreSessionTransaction(session));
    Set<Integer> expected = Set.of(db().query(BaseUserQueries.fetchUserId(playerUUID)).orElseThrow(AssertionError::new));
    Set<Integer> result = db().query(JoinAddressQueries.userIdsOfPlayersWithJoinAddresses(List.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP)));
    assertEquals(expected, result);
    Map<String, Integer> expectedAddressCounts = Map.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP, 1);
    Map<String, Integer> resultAddressCounts = db().query(JoinAddressQueries.latestJoinAddresses());
    assertEquals(expectedAddressCounts, resultAddressCounts);
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) Test(org.junit.jupiter.api.Test)

Example 3 with StoreSessionTransaction

use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.

the class JoinAddressQueriesTest method joinAddressQueryHasDistinctPlayers.

@Test
default void joinAddressQueryHasDistinctPlayers() {
    joinAddressCanBeUnknown();
    db().executeTransaction(TestData.storeServers());
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, player2UUID, playerUUID);
    String expectedAddress = TestConstants.GET_PLAYER_HOSTNAME.get();
    session.getExtraData().put(JoinAddress.class, new JoinAddress(expectedAddress));
    db().executeTransaction(new StoreSessionTransaction(session));
    Map<String, Integer> expected = Map.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP, 1, expectedAddress, 1);
    Map<String, Integer> result = db().query(JoinAddressQueries.latestJoinAddresses());
    assertEquals(expected, result);
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) JoinAddress(com.djrapitops.plan.gathering.domain.event.JoinAddress) Test(org.junit.jupiter.api.Test)

Example 4 with StoreSessionTransaction

use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.

the class ExportJSErrorRegressionTest method savePlayerData.

private static void savePlayerData() {
    DBSystem dbSystem = planSystem.getDatabaseSystem();
    Database database = dbSystem.getDatabase();
    UUID uuid = TestConstants.PLAYER_ONE_UUID;
    database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
    FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
    database.executeTransaction(new StoreSessionTransaction(session));
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) DBSystem(com.djrapitops.plan.storage.database.DBSystem) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Example 5 with StoreSessionTransaction

use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.

the class PlanPlaceholdersTest method storeSomeData.

private static void storeSomeData() {
    Database database = component.system().getDatabaseSystem().getDatabase();
    database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, System::currentTimeMillis, RandomData.randomString(5), serverUUID, () -> RandomData.randomString(5)));
    database.executeTransaction(new PlayerServerRegisterTransaction(TestConstants.PLAYER_TWO_UUID, System::currentTimeMillis, TestConstants.PLAYER_TWO_NAME, serverUUID, () -> RandomData.randomString(5)));
    String worldName = RandomData.randomString(10);
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName));
    database.executeTransaction(new StoreSessionTransaction(RandomData.randomSession(serverUUID, new String[] { worldName }, playerUUID, TestConstants.PLAYER_TWO_UUID)));
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)

Aggregations

StoreSessionTransaction (com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction)9 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)7 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)7 Test (org.junit.jupiter.api.Test)5 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)4 JoinAddress (com.djrapitops.plan.gathering.domain.event.JoinAddress)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)3 Database (com.djrapitops.plan.storage.database.Database)3 DataMap (com.djrapitops.plan.gathering.domain.DataMap)2 DBSystem (com.djrapitops.plan.storage.database.DBSystem)2 PlayerServerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)2 HtmlTable (com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable)1 CallEvents (com.djrapitops.plan.extension.CallEvents)1 DataExtension (com.djrapitops.plan.extension.DataExtension)1 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)1 NotReadyException (com.djrapitops.plan.extension.NotReadyException)1 com.djrapitops.plan.extension.annotation (com.djrapitops.plan.extension.annotation)1 ExtensionDataBuilder (com.djrapitops.plan.extension.builder.ExtensionDataBuilder)1 Color (com.djrapitops.plan.extension.icon.Color)1 Icon (com.djrapitops.plan.extension.icon.Icon)1