Fixes Inspect page issues, Fixed space in Server<id> string when default name was in use.

This commit is contained in:
Rsl1122 2017-08-28 21:57:48 +03:00
parent 150c4825fd
commit a2d7e6a3b2
9 changed files with 16 additions and 12 deletions

View File

@ -295,7 +295,7 @@ public class SessionsTable extends UserIDTable {
try {
statement = prepareStatement("SELECT " +
"(SUM(" + columnSessionEnd + ") - SUM(" + columnSessionStart + ")) as playtime, " +
columnServerID + "," +
columnServerID +
" FROM " + tableName +
" WHERE " + columnSessionStart + ">?" +
" AND " + columnUserID + "=" + usersTable.statementSelectID);

View File

@ -101,10 +101,13 @@ public class InspectPageParser {
.collect(Collectors.toList());
int sessionCountDay = sessionsDay.size();
int sessionCountWeek = sessionsDay.size();
int sessionCountWeek = sessionsWeek.size();
long playtimeDay = AnalysisUtils.getTotalPlaytime(sessionsDay);
long playtimeWeek = AnalysisUtils.getTotalPlaytime(sessionsWeek);
addValue("sessionLengthLongestDay", FormatUtils.formatTimeAmount(sessionsDay.get(0).getLength()));
addValue("sessionLengthLongestWeek", FormatUtils.formatTimeAmount(sessionsWeek.get(0).getLength()));
addValue("sessionCountDay", sessionCountDay);
addValue("sessionCountWeek", sessionCountWeek);
addValue("playtimeDay", FormatUtils.formatTimeAmount(playtimeDay));
@ -130,7 +133,9 @@ public class InspectPageParser {
addValue("lastSeen", FormatUtils.formatTimeAmount(playTime));
String puchCardData = PunchCardGraphCreator.createDataSeries(allSessions);
List<Session> sessionsInLengthOrder = allSessions.stream().sorted(new SessionLengthComparator()).collect(Collectors.toList());
List<Session> sessionsInLengthOrder = allSessions.stream()
.sorted(new SessionLengthComparator())
.collect(Collectors.toList());
if (sessionsInLengthOrder.isEmpty()) {
addValue("sessionLengthMedian", "No Sessions");
addValue("sessionLengthLongest", "No Sessions");
@ -163,7 +168,7 @@ public class InspectPageParser {
String banned = isBanned ? "Banned" : "";
String op = isOP ? "Operator (OP)" : "";
addValue("playerclassification", HtmlStructure.separateWithDots(active, banned, op));
addValue("playerClassification", HtmlStructure.separateWithDots(active, banned, op));
}
private void addValue(String placeholder, Serializable value) {

View File

@ -73,7 +73,7 @@ public class ServerInfoManager {
String name = Settings.SERVER_NAME.toString();
String webAddress = plugin.getWebServer().getAccessAddress();
if ("plan".equalsIgnoreCase(name)) {
name = "Server" + serverID.get();
name = "Server " + serverID.get();
}
serverInfo = new ServerInfo(serverID.get(), serverUUID, name, webAddress);

View File

@ -11,6 +11,6 @@ public class SessionLengthComparator implements Comparator<Session> {
@Override
public int compare(Session s1, Session s2) {
return Long.compare(s1.getLength(), s2.getLength());
return -Long.compare(s1.getLength(), s2.getLength());
}
}

View File

@ -11,6 +11,6 @@ public class SessionStartComparator implements Comparator<Session> {
@Override
public int compare(Session s1, Session s2) {
return Long.compare(s1.getSessionStart(), s2.getSessionStart());
return -Long.compare(s1.getSessionStart(), s2.getSessionStart());
}
}

View File

@ -12,6 +12,6 @@ public class StringLengthComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
return -Integer.compare(o1.length(), o2.length());
return Long.compare(o1.length(), o2.length());
}
}

View File

@ -48,9 +48,7 @@ public class HtmlStructure {
}
builder.append("&#x2022; ");
builder.append(element);
if (i < elements.length - 1) {
builder.append("<br>");
}
builder.append("<br>");
}
return builder.toString();
}

View File

@ -36,7 +36,7 @@ public class ActionsTableCreator {
long date = action.getDate();
html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse(
String.valueOf(date), FormatUtils.formatTimeStamp(date),
String.valueOf(date), FormatUtils.formatTimeStampYear(date),
action.getDoneAction().toString(),
action.getAdditionalInfo()
));

View File

@ -35,6 +35,7 @@ public class ComparatorTest {
List<Session> test = RandomData.randomSessions();
List<Long> longValues = test.stream().map(Session::getSessionStart).collect(Collectors.toList());
longValues.sort(Long::compare);
Collections.reverse(longValues);
test.sort(new SessionStartComparator());
List<Long> afterSort = test.stream().map(Session::getSessionStart).collect(Collectors.toList());
assertEquals(longValues, afterSort);