use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery in project Plan by plan-player-analytics.
the class JSONFactory method serverPlayersTableJSON.
public Map<String, Object> serverPlayersTableJSON(ServerUUID serverUUID) {
Integer xMostRecentPlayers = config.get(DisplaySettings.PLAYERS_PER_SERVER_PAGE);
Long playtimeThreshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
boolean openPlayerLinksInNewTab = config.isTrue(DisplaySettings.OPEN_PLAYER_LINKS_IN_NEW_TAB);
Database database = dbSystem.getDatabase();
return new PlayersTableJSONCreator(database.query(new ServerTablePlayersQuery(serverUUID, System.currentTimeMillis(), playtimeThreshold, xMostRecentPlayers)), database.query(new ExtensionServerTableDataQuery(serverUUID, xMostRecentPlayers)), openPlayerLinksInNewTab, formatters, locale).toJSONMap();
}
use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery in project Plan by plan-player-analytics.
the class JSONFactory method networkPlayersTableJSON.
public Map<String, Object> networkPlayersTableJSON() {
Integer xMostRecentPlayers = config.get(DisplaySettings.PLAYERS_PER_PLAYERS_PAGE);
Long playtimeThreshold = config.get(TimeSettings.ACTIVE_PLAY_THRESHOLD);
boolean openPlayerLinksInNewTab = config.isTrue(DisplaySettings.OPEN_PLAYER_LINKS_IN_NEW_TAB);
Database database = dbSystem.getDatabase();
ServerUUID mainServerUUID = database.query(ServerQueries.fetchProxyServerInformation()).map(Server::getUuid).orElse(serverInfo.getServerUUID());
Map<UUID, ExtensionTabData> pluginData = database.query(new ExtensionServerTableDataQuery(mainServerUUID, xMostRecentPlayers));
return new PlayersTableJSONCreator(database.query(new NetworkTablePlayersQuery(System.currentTimeMillis(), playtimeThreshold, xMostRecentPlayers)), pluginData, openPlayerLinksInNewTab, formatters, locale, // players page
true).toJSONMap();
}
use of com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionPlayerValuesCanBeQueriedAsTableData.
@Test
default void extensionPlayerValuesCanBeQueriedAsTableData() {
extensionPlayerValuesAreStored();
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
// Store a session to check against issue https://github.com/plan-player-analytics/Plan/issues/1039
ActiveSession session = new ActiveSession(playerUUID, serverUUID(), 32345L, worlds[0], "SURVIVAL");
session.getExtraData().put(WorldTimes.class, RandomData.randomWorldTimes(worlds));
execute(DataStoreQueries.storeSession(session.toFinishedSession(42345L)));
Map<UUID, ExtensionTabData> result = db().query(new ExtensionServerTableDataQuery(serverUUID(), 50));
assertEquals(1, result.size());
ExtensionTabData playerData = result.get(playerUUID);
assertNotNull(playerData);
OptionalAssert.equals("5", playerData.getNumber("value").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("No", playerData.getBoolean("boolVal").map(ExtensionBooleanData::getFormattedValue));
OptionalAssert.equals("0.5", playerData.getDouble("doubleVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("0.5", playerData.getPercentage("percentageVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("Something", playerData.getString("stringVal").map(ExtensionStringData::getFormattedValue));
}
Aggregations