Adding games played count to login screen.
This commit is contained in:
@@ -113,4 +113,31 @@ public class GameHistoryDAO {
|
||||
throw new RuntimeException("Unable to get count of player games", exp);
|
||||
}
|
||||
}
|
||||
|
||||
public int getGamesPlayedCountInLastMs(long ms) {
|
||||
try {
|
||||
Connection connection = _dbAccess.getDataSource().getConnection();
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("select count(*) from game_history where end_date>=?");
|
||||
try {
|
||||
statement.setLong(1, System.currentTimeMillis() - ms);
|
||||
ResultSet rs = statement.executeQuery();
|
||||
try {
|
||||
if (rs.next())
|
||||
return rs.getInt(1);
|
||||
else
|
||||
return -1;
|
||||
} finally {
|
||||
rs.close();
|
||||
}
|
||||
} finally {
|
||||
statement.close();
|
||||
}
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
} catch (SQLException exp) {
|
||||
throw new RuntimeException("Unable to get count of games played", exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,10 @@ public class LotroServer extends AbstractServer {
|
||||
return _gameHistoryDao.getGameHistoryForPlayerCount(player);
|
||||
}
|
||||
|
||||
public int getGamesPlayedCountInLastMs(long ms) {
|
||||
return _gameHistoryDao.getGamesPlayedCountInLastMs(ms);
|
||||
}
|
||||
|
||||
public LotroCardBlueprintLibrary getLotroCardBlueprintLibrary() {
|
||||
return _lotroCardBlueprintLibrary;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,9 @@ public class ServerResource {
|
||||
sb.append("<script>location.href='hall.html';</script>");
|
||||
} else {
|
||||
sb.append("You are not logged in, log in below or <button id='clickToRegister'>register</button>.");
|
||||
sb.append("<div class='status'>Tables count: ").append(_hallServer.getTablesCount()).append(", players in hall: ").append(_chatServer.getChatRoom("Game Hall").getUsersInRoom().size()).append("</div>");
|
||||
sb.append("<div class='status'>Tables count: ").append(_hallServer.getTablesCount()).append(", players in hall: ").append(_chatServer.getChatRoom("Game Hall").getUsersInRoom().size())
|
||||
.append(", games played in last 24 hours: ").append(_lotroServer.getGamesPlayedCountInLastMs(1000 * 60 * 60 * 24))
|
||||
.append("</div>");
|
||||
sb.append(getLoginHTML());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user