use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllWorldNames.
private static Executable storeAllWorldNames(Collection<FinishedSession> sessions, Set<World> existingWorlds) {
Set<World> worlds = sessions.stream().flatMap(session -> {
ServerUUID serverUUID = session.getServerUUID();
return session.getExtraData(WorldTimes.class).map(WorldTimes::getWorldTimes).map(Map::keySet).orElseGet(Collections::emptySet).stream().map(worldName -> new World(worldName, serverUUID));
}).filter(world -> !existingWorlds.contains(world)).collect(Collectors.toSet());
if (worlds.isEmpty())
return Executable.empty();
return new ExecBatchStatement(WorldTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
for (World world : worlds) {
statement.setString(1, world.getWorldName());
statement.setString(2, world.getServerUUID().toString());
statement.addBatch();
}
}
};
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllPingData.
public static Executable storeAllPingData(Map<UUID, List<Ping>> ofUsers) {
if (ofUsers == null || ofUsers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(PingTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
for (Map.Entry<UUID, List<Ping>> entry : ofUsers.entrySet()) {
UUID uuid = entry.getKey();
List<Ping> pings = entry.getValue();
for (Ping ping : pings) {
ServerUUID serverUUID = ping.getServerUUID();
long date = ping.getDate();
int minPing = ping.getMin();
int maxPing = ping.getMax();
double avgPing = ping.getAverage();
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setLong(3, date);
statement.setInt(4, minPing);
statement.setInt(5, maxPing);
statement.setDouble(6, avgPing);
statement.addBatch();
}
}
}
};
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PluginBooleanGroupFilter method getMatchingUUIDs.
@Override
public Set<UUID> getMatchingUUIDs(InputFilterDto query) {
Map<PluginBooleanOption, SelectedBoolean> selectedBooleanOptions = new HashMap<>();
for (String selected : getSelected(query)) {
String[] optionAndBoolean = StringUtils.split(selected, ":", 2);
PluginBooleanOption pluginBooleanOption = PluginBooleanOption.parse(optionAndBoolean[0].trim());
String selectedBoolean = optionAndBoolean[1].trim().toUpperCase();
selectedBooleanOptions.computeIfPresent(pluginBooleanOption, (key, existing) -> SelectedBoolean.BOTH);
selectedBooleanOptions.computeIfAbsent(pluginBooleanOption, key -> SelectedBoolean.valueOf(selectedBoolean));
}
Database db = dbSystem.getDatabase();
Map<String, ServerUUID> namesToUUIDs = db.query(ServerQueries.fetchServerNamesToUUIDs());
return db.query(playersInGroups(selectedBooleanOptions, namesToUUIDs));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PingQueries method fetchPingDataOfServer.
public static Query<List<Ping>> fetchPingDataOfServer(long after, long before, ServerUUID serverUUID) {
String sql = SELECT + PingTable.DATE + ", " + PingTable.MAX_PING + ", " + PingTable.MIN_PING + ", " + PingTable.AVG_PING + ", " + PingTable.SERVER_UUID + FROM + PingTable.TABLE_NAME + WHERE + PingTable.SERVER_UUID + "=?" + AND + PingTable.DATE + ">=?" + AND + PingTable.DATE + "<=?";
return new QueryStatement<List<Ping>>(sql, 1000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
statement.setLong(2, after);
statement.setLong(3, before);
}
@Override
public List<Ping> processResults(ResultSet set) throws SQLException {
List<Ping> pings = new ArrayList<>();
while (set.next()) {
ServerUUID serverUUID = ServerUUID.fromString(set.getString(PingTable.SERVER_UUID));
long date = set.getLong(PingTable.DATE);
double avgPing = set.getDouble(PingTable.AVG_PING);
int minPing = set.getInt(PingTable.MIN_PING);
int maxPing = set.getInt(PingTable.MAX_PING);
pings.add(new Ping(date, serverUUID, minPing, maxPing, avgPing));
}
return pings;
}
};
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class NicknameQueries method fetchNicknameDataOfServer.
/**
* Query database for nickname information of a server.
*
* @param serverUUID UUID the the Plan server.
* @return Map: Player UUID - List of Nicknames on the server.
*/
public static Query<Map<UUID, List<Nickname>>> fetchNicknameDataOfServer(ServerUUID serverUUID) {
String sql = SELECT + NicknamesTable.NICKNAME + ',' + NicknamesTable.LAST_USED + ',' + NicknamesTable.USER_UUID + FROM + NicknamesTable.TABLE_NAME + WHERE + NicknamesTable.SERVER_UUID + "=?";
return new QueryStatement<Map<UUID, List<Nickname>>>(sql, 5000) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
statement.setString(1, serverUUID.toString());
}
@Override
public Map<UUID, List<Nickname>> processResults(ResultSet set) throws SQLException {
Map<UUID, List<Nickname>> serverMap = new HashMap<>();
while (set.next()) {
UUID uuid = UUID.fromString(set.getString(NicknamesTable.USER_UUID));
List<Nickname> nicknames = serverMap.computeIfAbsent(uuid, Lists::create);
nicknames.add(new Nickname(set.getString(NicknamesTable.NICKNAME), set.getLong(NicknamesTable.LAST_USED), serverUUID));
}
return serverMap;
}
};
}
Aggregations