Refactoring game history.

This commit is contained in:
marcins78
2012-12-26 00:19:24 +00:00
parent 650866b14c
commit 3a82bab75e
3 changed files with 1 additions and 35 deletions

View File

@@ -155,9 +155,7 @@ public class DbGameHistoryDAO implements GameHistoryDAO {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
// 5 minutes minimum game
long minTime = 1000 * 60 * 5;
PreparedStatement statement = connection.prepareStatement("select count(*) from game_history where end_date>=? and end_date<? and end_date-start_date>" + minTime);
PreparedStatement statement = connection.prepareStatement("select count(*) from game_history where end_date>=? and end_date<?");
try {
statement.setLong(1, from);
statement.setLong(2, from + duration);
@@ -181,32 +179,6 @@ public class DbGameHistoryDAO implements GameHistoryDAO {
}
}
public long getOldestGameHistoryEntry() {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {
PreparedStatement statement = connection.prepareStatement("select min(end_date) from game_history where (tournament is null or tournament = 'Casual')");
try {
ResultSet rs = statement.executeQuery();
try {
if (rs.next())
return rs.getLong(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);
}
}
public Map<String, Integer> getCasualGamesPlayedPerFormat(long from, long duration) {
try {
Connection connection = _dbAccess.getDataSource().getConnection();

View File

@@ -18,8 +18,6 @@ public interface GameHistoryDAO {
public int getGamesPlayedCount(long from, long duration);
public long getOldestGameHistoryEntry();
public Map<String, Integer> getCasualGamesPlayedPerFormat(long from, long duration);
public List<PlayerStatistic> getCasualPlayerStatistics(Player player);

View File

@@ -48,10 +48,6 @@ public class GameHistoryService {
return _gameHistoryDAO.getGamesPlayedCount(from, duration);
}
public long getOldestGameHistoryEntry() {
return _gameHistoryDAO.getOldestGameHistoryEntry();
}
public GameHistoryStatistics getGameHistoryStatistics(long from, long duration) {
GameHistoryStatistics stats = new GameHistoryStatistics(from, duration);
stats.init(_gameHistoryDAO);