Refactoring game history.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user