mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-29 12:37:40 +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.file.FileUtil;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
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 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);
|
||||
html.append(tableContainer.parseHeader());
|
||||
|
||||
try {
|
||||
if (users.isEmpty()) {
|
||||
@ -77,7 +79,6 @@ public class PlayersPageResponse extends Response {
|
||||
throw new IllegalArgumentException("No players");
|
||||
}
|
||||
|
||||
List<String[]> sortedData = new ArrayList<>();
|
||||
API planAPI = Plan.getPlanAPI();
|
||||
|
||||
int i = 0;
|
||||
@ -104,23 +105,20 @@ public class PlayersPageResponse extends Response {
|
||||
geoInfoList.sort(new GeoInfoComparator());
|
||||
String geolocation = geoInfoList.isEmpty() ? "Not Known" : geoInfoList.get(0).getGeolocation();
|
||||
|
||||
playerData[0] = link;
|
||||
playerData[1] = FormatUtils.formatTimeAmount(playtime);
|
||||
playerData[2] = sessionCount + "";
|
||||
playerData[3] = FormatUtils.formatTimeStampYear(registered);
|
||||
playerData[4] = lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-";
|
||||
playerData[5] = geolocation;
|
||||
sortedData.add(playerData);
|
||||
html.append(Html.TABLELINE_PLAYERS_PLAYERS_PAGE.parse(
|
||||
link,
|
||||
playtime, FormatUtils.formatTimeAmount(playtime),
|
||||
sessionCount + "",
|
||||
FormatUtils.formatTimeStampYear(registered),
|
||||
lastSeen != 0 ? FormatUtils.formatTimeStampYear(lastSeen) : "-",
|
||||
geolocation
|
||||
));
|
||||
i++;
|
||||
}
|
||||
|
||||
for (String[] playerData : sortedData) {
|
||||
tableContainer.addRow(ArrayUtils.addAll(playerData));
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
return tableContainer.parseHtml().replace(Html.TABLE_SCROLL.parse(),
|
||||
"<table class=\"table table-bordered table-striped table-hover player-table dataTable\">");
|
||||
return html.append("</tbody></table>").toString();
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(PlayersPageResponse.class.getClass().getName(), e);
|
||||
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_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_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_1("<tr><td sorttable_customkey=\"${0}\">${1}</td><td>${2}</td><td>${3}</td></tr>");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user