Adding games played count to login screen.

This commit is contained in:
marcins78@gmail.com
2011-11-10 01:36:31 +00:00
parent cb71e05119
commit 9408da9c2f
3 changed files with 34 additions and 1 deletions

View File

@@ -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);
}
}
}

View File

@@ -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;
}

View File

@@ -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());
}