use of com.djrapitops.plan.storage.database.transactions.Executable 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();
}
}
};
}
Aggregations