mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 14:07:54 +01:00
Fixed Playtime sorting
This commit is contained in:
parent
7e79ec02d2
commit
d79add8745
@ -20,7 +20,6 @@ import main.java.com.djrapitops.plan.utilities.comparators.GeoInfoComparator;
|
|||||||
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
|
import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedComparator;
|
||||||
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -69,7 +68,10 @@ public class PlayersPageResponse extends Response {
|
|||||||
String lastSeenS = Html.FONT_AWESOME_ICON.parse("calendar-check-o") + " Last Seen";
|
String lastSeenS = Html.FONT_AWESOME_ICON.parse("calendar-check-o") + " Last Seen";
|
||||||
String geolocationS = Html.FONT_AWESOME_ICON.parse("globe") + " Geolocation";
|
String geolocationS = Html.FONT_AWESOME_ICON.parse("globe") + " Geolocation";
|
||||||
|
|
||||||
|
StringBuilder html = new StringBuilder("<table class=\"table table-bordered table-striped table-hover player-table dataTable\">");
|
||||||
|
|
||||||
TableContainer tableContainer = new TableContainer(userS, playtimeS, sessionsS, registeredS, lastSeenS, geolocationS);
|
TableContainer tableContainer = new TableContainer(userS, playtimeS, sessionsS, registeredS, lastSeenS, geolocationS);
|
||||||
|
html.append(tableContainer.parseHeader());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (users.isEmpty()) {
|
if (users.isEmpty()) {
|
||||||
@ -77,7 +79,6 @@ public class PlayersPageResponse extends Response {
|
|||||||
throw new IllegalArgumentException("No players");
|
throw new IllegalArgumentException("No players");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String[]> sortedData = new ArrayList<>();
|
|
||||||
API planAPI = Plan.getPlanAPI();
|
API planAPI = Plan.getPlanAPI();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -104,23 +105,20 @@ public class PlayersPageResponse extends Response {
|
|||||||
geoInfoList.sort(new GeoInfoComparator());
|
geoInfoList.sort(new GeoInfoComparator());
|
||||||
String geolocation = geoInfoList.isEmpty() ? "Not Known" : geoInfoList.get(0).getGeolocation();
|
String geolocation = geoInfoList.isEmpty() ? "Not Known" : geoInfoList.get(0).getGeolocation();
|
||||||
|
|
||||||
playerData[0] = link;
|
html.append(Html.TABLELINE_PLAYERS_PLAYERS_PAGE.parse(
|
||||||
playerData[1] = FormatUtils.formatTimeAmount(playtime);
|
link,
|
||||||
playerData[2] = sessionCount + "";
|
playtime, FormatUtils.formatTimeAmount(playtime),
|
||||||
playerData[3] = FormatUtils.formatTimeStampYear(registered);
|
sessionCount + "",
|
||||||
playerData[4] = lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-";
|
FormatUtils.formatTimeStampYear(registered),
|
||||||
playerData[5] = geolocation;
|
lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-",
|
||||||
sortedData.add(playerData);
|
geolocation
|
||||||
|
));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String[] playerData : sortedData) {
|
|
||||||
tableContainer.addRow(ArrayUtils.addAll(playerData));
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
return tableContainer.parseHtml().replace(Html.TABLE_SCROLL.parse(),
|
return html.append("</tbody></table>").toString();
|
||||||
"<table class=\"table table-bordered table-striped table-hover player-table dataTable\">");
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(PlayersPageResponse.class.getClass().getName(), e);
|
Log.toLog(PlayersPageResponse.class.getClass().getName(), e);
|
||||||
return new InternalErrorResponse(e, "/players").getContent();
|
return new InternalErrorResponse(e, "/players").getContent();
|
||||||
|
@ -87,7 +87,8 @@ public enum Html {
|
|||||||
TABLELINE_2("<tr><td><b>${0}</b></td><td>${1}</td></tr>"),
|
TABLELINE_2("<tr><td><b>${0}</b></td><td>${1}</td></tr>"),
|
||||||
TABLELINE_3("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td></tr>"),
|
TABLELINE_3("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td></tr>"),
|
||||||
TABLELINE_4("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td><td>${3}</td></tr>"),
|
TABLELINE_4("<tr><td><b>${0}</b></td><td>${1}</td><td>${2}</td><td>${3}</td></tr>"),
|
||||||
TABLELINE_PLAYERS("<tr><td>${0}</td><td>${1}</td><td sorttable_customkey=\"${2}\">${3}</td><td>${4}</td><td sorttable_customkey=\"${5}\">${6}</td>" + "<td sorttable_customkey=\"${7}\">${8}</td><td>${9}</td></tr>"),
|
TABLELINE_PLAYERS("<tr><td>${0}</td><td>${1}</td><td data-order=\"${2}\">${3}</td><td>${4}</td><td data-order=\"${5}\">${6}</td>" + "<td data-order=\"${7}\">${8}</td><td>${9}</td></tr>"),
|
||||||
|
TABLELINE_PLAYERS_PLAYERS_PAGE("<tr><td>${0}</td><td data-order=\"${1}\">${2}</td><td>${4}</td><td>${5}</td>" + "<td>${6}</td><td>${7}</td></tr>"),
|
||||||
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"${0}\">${1}</td><td sorttable_customkey=\"${2}\">${3}</td><td sorttable_customkey=\"${4}\">${5}</td></tr>"),
|
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"${0}\">${1}</td><td sorttable_customkey=\"${2}\">${3}</td><td sorttable_customkey=\"${4}\">${5}</td></tr>"),
|
||||||
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"${0}\">${1}</td><td>${2}</td><td>${3}</td></tr>");
|
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"${0}\">${1}</td><td>${2}</td><td>${3}</td></tr>");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user