updated to handle new formatting
This commit is contained in:
parent
30145198f4
commit
a0879dd786
@ -21,7 +21,7 @@ public class MapBoardDTO {
|
||||
private String name;
|
||||
private String avatar;
|
||||
private int mapPoint;
|
||||
private String mapTime;
|
||||
private Float mapTime;
|
||||
private int position;
|
||||
private List<String> badgesUrls = new ArrayList();
|
||||
|
||||
@ -69,11 +69,11 @@ public class MapBoardDTO {
|
||||
this.mapPoint = mapPoint;
|
||||
}
|
||||
|
||||
public String getMapTime() {
|
||||
public Float getMapTime() {
|
||||
return mapTime;
|
||||
}
|
||||
|
||||
public void setMapTime(String mapTime) {
|
||||
public void setMapTime(Float mapTime) {
|
||||
this.mapTime = mapTime;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class MapValuesDTO {
|
||||
|
||||
private int position;
|
||||
private String playerSteamID;
|
||||
private String time;
|
||||
private Float time;
|
||||
private int mapPoints;
|
||||
|
||||
public int getPosition() {
|
||||
@ -34,11 +34,11 @@ public class MapValuesDTO {
|
||||
this.playerSteamID = playerSteamID;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
public Float getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
public void setTime(Float time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ public class PlayerMapBoardDTO {
|
||||
private String mapname;
|
||||
private int mapstage;
|
||||
private int mapPoint;
|
||||
private String mapTime;
|
||||
private Float mapTime;
|
||||
private int position;
|
||||
|
||||
public PlayerMapBoardDTO() {
|
||||
|
@ -30,33 +30,55 @@ public class DataMapperCalls {
|
||||
public static Map.Entry<Collection<Player>, Collection<MapBoard>> getAllValues() {
|
||||
Collection<Player> allPlayers = new ArrayList();
|
||||
ConcurrentMap<String, MapBoard> allMapBoards = new MapMaker().concurrencyLevel(4).makeMap();
|
||||
String sqlQuery = "SELECT * FROM `zetimer_table`";
|
||||
try (Connection con = DBCPDataSource.getConnection()) {
|
||||
try (PreparedStatement ps = con.prepareStatement(sqlQuery)) {
|
||||
String sqlQuery_size = "SELECT count(*) FROM `zetimer_table_new`";
|
||||
int rows_size = 0;
|
||||
try (PreparedStatement ps = con.prepareStatement(sqlQuery_size)) {
|
||||
try (ResultSet result = ps.executeQuery()) {
|
||||
int fetchSize = result.getMetaData().getColumnCount();
|
||||
while (result.next() /*&& limitfetch < 25*/) {
|
||||
int timesCounter = 0;
|
||||
Player player = new Player(result.getString(1), result.getString(2));
|
||||
//System.out.println("player dataMapper: " + player.getName() + "\nsteamid: " + player.getSteamID());
|
||||
int i = 3;
|
||||
while (i <= fetchSize) {
|
||||
String specificTime = result.getString(i);
|
||||
if (specificTime != null && !specificTime.equals("0.000")) {
|
||||
String columnLabel = result.getMetaData().getColumnLabel(i);
|
||||
if (!allMapBoards.keySet().contains(columnLabel)) {
|
||||
allMapBoards.put(columnLabel, new MapBoard(columnLabel));
|
||||
result.next();
|
||||
rows_size = result.getInt(1);
|
||||
}
|
||||
}
|
||||
//just a way to fetch 500 results at a time as seemingly struggling with just a select * from table statement.
|
||||
String last_steam_auth = "";
|
||||
while (allPlayers.size() < rows_size)
|
||||
{
|
||||
String sqlQuery = "select * from `zetimer_table_new` ztn where ztn.steam_auth > '" + last_steam_auth + "'\n" +
|
||||
"order by steam_auth asc limit 5000 ";
|
||||
if (allPlayers.size() == 0)
|
||||
{
|
||||
sqlQuery = "select * from `zetimer_table_new` ztn order by steam_auth asc limit 5000";
|
||||
}
|
||||
//System.out.println("sqlQuery: " + sqlQuery);
|
||||
try (PreparedStatement ps = con.prepareStatement(sqlQuery)) {
|
||||
ps.setFetchSize(100);
|
||||
//System.out.println("allplayers size: " + allPlayers.size() + " rows_size: " + rows_size);
|
||||
try (ResultSet result = ps.executeQuery()) {
|
||||
int fetchSize = result.getMetaData().getColumnCount();
|
||||
while (result.next() /*&& limitfetch < 25*/) {
|
||||
int timesCounter = 0;
|
||||
Player player = new Player(result.getString(1), result.getString(2));
|
||||
//System.out.println("player dataMapper: " + player.getName() + "\nsteamid: " + player.getSteamID());
|
||||
int i = 3;
|
||||
while (i <= fetchSize) {
|
||||
Float specificTime = result.getFloat(i);
|
||||
if (specificTime != null && specificTime != 0) {
|
||||
String columnLabel = result.getMetaData().getColumnLabel(i);
|
||||
if (!allMapBoards.keySet().contains(columnLabel)) {
|
||||
allMapBoards.put(columnLabel, new MapBoard(columnLabel));
|
||||
}
|
||||
timesCounter++;
|
||||
MapValues mapValue = new MapValues();
|
||||
mapValue.setPlayerSteamID(player.getSteamID());
|
||||
mapValue.setTime(specificTime);
|
||||
allMapBoards.get(columnLabel).getMapvalues().add(mapValue);
|
||||
}
|
||||
timesCounter++;
|
||||
MapValues mapValue = new MapValues();
|
||||
mapValue.setPlayerSteamID(player.getSteamID());
|
||||
mapValue.setTime(specificTime);
|
||||
allMapBoards.get(columnLabel).getMapvalues().add(mapValue);
|
||||
i++;
|
||||
}
|
||||
i++;
|
||||
player.setTimesCount(timesCounter);
|
||||
allPlayers.add(player);
|
||||
last_steam_auth = player.getSteamID();
|
||||
}
|
||||
player.setTimesCount(timesCounter);
|
||||
allPlayers.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,4 +136,4 @@ public class DataMapperCalls {
|
||||
}
|
||||
return new AbstractMap.SimpleEntry(map, stage);
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ public class MapValues implements Serializable {
|
||||
private String playerSteamID;
|
||||
@Basic(optional = false)
|
||||
@NotNull
|
||||
private String time;
|
||||
private Float time;
|
||||
@Basic(optional = false)
|
||||
@NotNull
|
||||
private int mapPoints;
|
||||
@ -75,11 +75,11 @@ public class MapValues implements Serializable {
|
||||
this.playerSteamID = steamID;
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
public Float getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String specificTime) {
|
||||
public void setTime(Float specificTime) {
|
||||
this.time = specificTime;
|
||||
}
|
||||
|
||||
|
@ -398,29 +398,12 @@ public class Facade {
|
||||
for (MapBoard mapboard : mapboards) {
|
||||
//System.out.println("mapName: " + mapboard.getMapName());
|
||||
List<MapValues> mapvalues = new ArrayList();
|
||||
List<MapValues> less_than_a_minute = new ArrayList<>();
|
||||
List<MapValues> less_than_10_seconds = new ArrayList<>();
|
||||
for (MapValues mv : mapboard.getMapvalues())
|
||||
{
|
||||
String time = mv.getTime();
|
||||
int indexOf = time.indexOf(".");
|
||||
if (indexOf == 1){
|
||||
less_than_10_seconds.add(mv);
|
||||
}
|
||||
else if (!time.contains(":"))
|
||||
{
|
||||
less_than_a_minute.add(mv);
|
||||
}
|
||||
else{
|
||||
mapvalues.add(mv);
|
||||
}
|
||||
mapvalues.add(mv);
|
||||
}
|
||||
less_than_10_seconds.sort(Comparator.comparing(MapValues::getTime));
|
||||
mapvalues.sort(Comparator.comparing(MapValues::getTime));
|
||||
less_than_a_minute.sort(Comparator.comparing(MapValues::getTime));
|
||||
less_than_10_seconds.addAll(less_than_a_minute);
|
||||
less_than_10_seconds.addAll(mapvalues);
|
||||
mapBoardCache.get(mapboard.getMapName()).setMapvalues(less_than_10_seconds);
|
||||
mapBoardCache.get(mapboard.getMapName()).setMapvalues(mapvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user