Fixed Last Seen on inspect page

This commit is contained in:
Rsl1122 2017-08-30 12:43:57 +03:00
parent f3ac5067b3
commit aaaa634638
2 changed files with 29 additions and 3 deletions

View File

@ -493,4 +493,24 @@ public class SessionsTable extends UserIDTable {
close(set, statement);
}
}
public long getLastSeen(UUID uuid) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
statement = prepareStatement("SELECT" +
" MAX(" + columnSessionEnd + ") as last_seen" +
" FROM " + tableName +
" WHERE " + columnUserID + "=" + usersTable.statementSelectID);
statement.setString(1, uuid.toString());
set = statement.executeQuery();
if (set.next()) {
return set.getLong("last_seen");
}
return 0;
} finally {
endTransaction(statement);
close(set, statement);
}
}
}

View File

@ -53,9 +53,12 @@ public class InspectPageParser {
}
public String parse() throws SQLException, FileNotFoundException {
// TODO Player is online parts
Log.debug("Database", "Inspect Parse Fetch");
Benchmark.start("Inspect Parse, Fetch");
Database db = plugin.getDB();
SessionsTable sessionsTable = db.getSessionsTable();
UserInfo userInfo = db.getUserInfoTable().getUserInfo(uuid);
int timesKicked = db.getUsersTable().getTimesKicked(uuid);
@ -64,11 +67,14 @@ public class InspectPageParser {
addValue("playerName", userInfo.getName());
addValue("registered", FormatUtils.formatTimeStampYear(userInfo.getRegistered()));
long lastSeen = userInfo.getLastSeen();
addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen));
long lastSeen = sessionsTable.getLastSeen(uuid);
if (lastSeen != 0) {
addValue("lastSeen", FormatUtils.formatTimeStampYear(lastSeen));
} else {
addValue("lastSeen", "-");
}
addValue("kickCount", timesKicked);
SessionsTable sessionsTable = db.getSessionsTable();
Map<String, Long> playtimeByServer = sessionsTable.getPlaytimeByServer(uuid);
List<String> geolocations = db.getIpsTable().getGeolocations(uuid);