Skip to content
Snippets Groups Projects
Commit 9dd7c592 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#374 Fixed game records sync doubling

parent f312bc49
Branches
Tags
No related merge requests found
......@@ -157,7 +157,11 @@ public class GameDAO {
public static final String GAME_SELECT_FOR_USER_AND_DEFINITION = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time FROM game WHERE user_id = ? AND game_number = ? AND end_time IS NOT NULL AND end_time != 0 ORDER BY start_time ASC";
public static final String GAME_SELECT_COUNT_FOR_GAME = "SELECT count(id) FROM game WHERE game_number = ? AND user_id = ?";
public static final String GAME_SELECT_ALL_FOR_USER_SYNC = "SELECT id, user_id, difficulty_number, game_number, random_seed, start_time, end_time FROM game where user_id = ? AND sync_at is null";
public static final String GAME_SELECT_BY_START_AND_END = "SELECT id FROM game WHERE user_id = ? AND start_time = ? AND end_time = ?";
public static final String GAME_SELECT_BY_START_AND_NULL_END = "SELECT id FROM game WHERE user_id = ? AND start_time = ? AND end_time IS NULL";
public static final String GAME_SELECT_LAST_SCORES_FOR_USER_AND_GAME = "SELECT value FROM game_score INNER JOIN game ON game_score.game_id=game.id AND game.user_id=? AND game.game_number=? WHERE game_score.key=? AND end_time IS NOT NULL ORDER BY game_id DESC LIMIT 1";
public static final String GAME_SELECT_FOR_RANK_MANAGER = "SELECT id, difficulty_number, game_number, start_time, end_time FROM game WHERE user_id = ? AND end_time IS NOT NULL AND end_time != 0 ORDER BY end_time ASC";
......@@ -222,10 +226,17 @@ public class GameDAO {
}
public static Long selectGameByTimes(long userId, long startTime, long endTime) throws SQLException {
PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(GAME_SELECT_BY_START_AND_END);
// workaround for sync error -> serialized JSON from server contains 0 instead of NULL
// PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(GAME_SELECT_BY_START_AND_END);
PreparedStatement statement = TablexiaStorage.getInstance().prepareStatement(endTime != 0 ? GAME_SELECT_BY_START_AND_END : GAME_SELECT_BY_START_AND_NULL_END);
statement.setLong(1, userId);
statement.setLong(2, startTime);
statement.setLong(3, endTime);
// workaround for sync error -> serialized JSON from server contains 0 instead of NULL
// statement.setLong(3, endTime);
if (endTime != 0) {
statement.setLong(3, endTime);
}
Long gameId = null;
ResultSet resultSet = statement.executeQuery();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment