use of com.djrapitops.plan.storage.database.queries.QueryAllStatement in project Plan by plan-player-analytics.
the class RegisterDateMinimizationPatch method fetchSmallestServerRegisterDates.
private Query<Map<UUID, Long>> fetchSmallestServerRegisterDates() {
String selectSmallestRegisterDates = SELECT + UserInfoTable.USER_ID + ',' + "MIN(" + UserInfoTable.REGISTERED + ") as min_registered" + FROM + UserInfoTable.TABLE_NAME + GROUP_BY + UserInfoTable.USER_ID;
String sql = SELECT + UsersTable.USER_UUID + ",u1." + UsersTable.REGISTERED + ",min_registered" + FROM + '(' + selectSmallestRegisterDates + ") u2" + INNER_JOIN + UsersTable.TABLE_NAME + " u1 on u1." + UsersTable.ID + "=u2." + UserInfoTable.USER_ID + WHERE + "u1." + UsersTable.REGISTERED + ">min_registered";
return new QueryAllStatement<Map<UUID, Long>>(sql, 500) {
@Override
public Map<UUID, Long> processResults(ResultSet set) throws SQLException {
Map<UUID, Long> dates = new HashMap<>();
while (set.next()) {
UUID playerUUID = UUID.fromString(set.getString(UsersTable.USER_UUID));
long newRegisterDate = set.getLong("min_registered");
dates.put(playerUUID, newRegisterDate);
}
return dates;
}
};
}
use of com.djrapitops.plan.storage.database.queries.QueryAllStatement in project Plan by plan-player-analytics.
the class UserIdentifierQueries method fetchAllPlayerUUIDs.
/**
* Query database for all player UUIDs stored in the Plan database.
*
* @return Set of UUIDs.
*/
public static Query<Set<UUID>> fetchAllPlayerUUIDs() {
String sql = Select.from(UsersTable.TABLE_NAME, UsersTable.USER_UUID).toString();
return new QueryAllStatement<Set<UUID>>(sql, 20000) {
@Override
public Set<UUID> processResults(ResultSet set) throws SQLException {
Set<UUID> playerUUIDs = new HashSet<>();
while (set.next()) {
UUID playerUUID = UUID.fromString(set.getString(UsersTable.USER_UUID));
playerUUIDs.add(playerUUID);
}
return playerUUIDs;
}
};
}
use of com.djrapitops.plan.storage.database.queries.QueryAllStatement in project Plan by plan-player-analytics.
the class UserInfoQueries method fetchAllUserInformation.
/**
* Query database for user information.
* <p>
* The user information does not contain player names.
*
* @return Map: Server UUID - List of user information
*/
public static Query<Map<ServerUUID, List<UserInfo>>> fetchAllUserInformation() {
String sql = SELECT + "ux." + UserInfoTable.REGISTERED + ',' + UserInfoTable.BANNED + ',' + UserInfoTable.OP + ',' + "u." + UsersTable.USER_UUID + ',' + "s." + ServerTable.SERVER_UUID + " as server_uuid," + UserInfoTable.JOIN_ADDRESS + FROM + UserInfoTable.TABLE_NAME + " ux" + INNER_JOIN + UsersTable.TABLE_NAME + " u on u." + UsersTable.ID + '=' + "ux." + UserInfoTable.USER_ID + INNER_JOIN + ServerTable.TABLE_NAME + " s on s." + ServerTable.ID + '=' + "ux." + UserInfoTable.SERVER_ID;
return new QueryAllStatement<Map<ServerUUID, List<UserInfo>>>(sql, 50000) {
@Override
public Map<ServerUUID, List<UserInfo>> processResults(ResultSet set) throws SQLException {
Map<ServerUUID, List<UserInfo>> serverMap = new HashMap<>();
while (set.next()) {
ServerUUID serverUUID = ServerUUID.fromString(set.getString("server_uuid"));
UUID uuid = UUID.fromString(set.getString(UsersTable.USER_UUID));
List<UserInfo> userInfos = serverMap.computeIfAbsent(serverUUID, Lists::create);
long registered = set.getLong(UserInfoTable.REGISTERED);
boolean banned = set.getBoolean(UserInfoTable.BANNED);
boolean op = set.getBoolean(UserInfoTable.OP);
String joinAddress = set.getString(UserInfoTable.JOIN_ADDRESS);
userInfos.add(new UserInfo(uuid, serverUUID, registered, op, joinAddress, banned));
}
return serverMap;
}
};
}
use of com.djrapitops.plan.storage.database.queries.QueryAllStatement in project Plan by plan-player-analytics.
the class ExtensionInformationQueries method allExtensions.
public static Query<Map<ServerUUID, List<ExtensionInformation>>> allExtensions() {
String sql = SELECT + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.ID + " as id," + ExtensionPluginTable.TABLE_NAME + '.' + ExtensionPluginTable.PLUGIN_NAME + " as plugin_name," + ExtensionPluginTable.SERVER_UUID + ',' + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ICON_NAME + " as icon_name," + ExtensionIconTable.COLOR + ',' + ExtensionIconTable.FAMILY + FROM + ExtensionPluginTable.TABLE_NAME + INNER_JOIN + ExtensionIconTable.TABLE_NAME + " on " + ExtensionPluginTable.ICON_ID + "=" + ExtensionIconTable.TABLE_NAME + '.' + ExtensionIconTable.ID;
return new QueryAllStatement<Map<ServerUUID, List<ExtensionInformation>>>(sql, 100) {
@Override
public Map<ServerUUID, List<ExtensionInformation>> processResults(ResultSet set) throws SQLException {
Map<ServerUUID, List<ExtensionInformation>> byServerUUID = new HashMap<>();
while (set.next()) {
ServerUUID serverUUID = ServerUUID.fromString(set.getString(ExtensionPluginTable.SERVER_UUID));
List<ExtensionInformation> information = byServerUUID.computeIfAbsent(serverUUID, Lists::create);
information.add(extractExtensionInformationFromQuery(set));
}
return byServerUUID;
}
};
}
Aggregations