Fixed multiples of same geolocation on player page

This commit is contained in:
Rsl1122 2019-08-25 11:18:15 +03:00
parent 63434cc8e0
commit 5021ada67f
2 changed files with 8 additions and 4 deletions

View File

@ -89,6 +89,7 @@ public class GeoInfo implements DateHolder, Serializable {
}
}
@Deprecated
public String getIp() {
return ip;
}

View File

@ -86,8 +86,12 @@ public class GeoInfoQueries {
* @return List of {@link GeoInfo}, empty if none are found.
*/
public static Query<List<GeoInfo>> fetchPlayerGeoInformation(UUID playerUUID) {
String sql = SELECT + DISTINCT + '*' + FROM + GeoInfoTable.TABLE_NAME +
WHERE + GeoInfoTable.USER_UUID + "=?";
String sql = SELECT +
GeoInfoTable.GEOLOCATION +
",MAX(" + GeoInfoTable.LAST_USED + ") as " + GeoInfoTable.LAST_USED +
FROM + GeoInfoTable.TABLE_NAME +
WHERE + GeoInfoTable.USER_UUID + "=?" +
GROUP_BY + GeoInfoTable.GEOLOCATION;
return new QueryStatement<List<GeoInfo>>(sql, 100) {
@Override
@ -99,10 +103,9 @@ public class GeoInfoQueries {
public List<GeoInfo> processResults(ResultSet set) throws SQLException {
List<GeoInfo> geoInfo = new ArrayList<>();
while (set.next()) {
String ip = set.getString(GeoInfoTable.IP);
String geolocation = set.getString(GeoInfoTable.GEOLOCATION);
long lastUsed = set.getLong(GeoInfoTable.LAST_USED);
geoInfo.add(new GeoInfo(ip, geolocation, lastUsed));
geoInfo.add(new GeoInfo("", geolocation, lastUsed));
}
return geoInfo;
}