Hot Fix groups
This commit is contained in:
parent
b223b6bad4
commit
e78ef96cfd
2 changed files with 8 additions and 14 deletions
|
@ -51,11 +51,8 @@ public enum DatabaseQuery {
|
|||
"SELECT * FROM completions WHERE fk_puzzle = ? AND fk_player = ?"),
|
||||
GET_COMPLETION_GROUP("SELECT c.*\r\n"
|
||||
+ "FROM completions c\r\n"
|
||||
+ "JOIN containsGroups cG on c.fk_player = cG.fk_player\r\n"
|
||||
+ "JOIN groups g on cG.fk_group = g.id_group\r\n"
|
||||
+ "JOIN puzzles p on p.id_puzzle = c.fk_puzzle\r\n"
|
||||
+ "JOIN chapters ch on ch.id_chapter = p.fk_chapter\r\n"
|
||||
+ "WHERE (ch.id_chapter = 12) AND cG.fk_player = ? AND p.id_puzzle = ?"),
|
||||
+ "WHERE c.fk_puzzle = ? AND c.fk_player IN\r\n"
|
||||
+ "(select f.fk_player FROM containsGroups cgs JOIN containsGroups f ON f.fk_group = cgs.fk_group JOIN groups g ON g.id_group = cgs.fk_group WHERE g.fk_chapter = 12 AND cgs.fk_player = ?)"),
|
||||
INSERT_COMPLETION(
|
||||
"INSERT INTO completions (fk_puzzle, fk_player, tries, code, fileName, score) values (?, ?, ?, ?, ?, ?)"),
|
||||
UPDATE_COMPLETION(
|
||||
|
@ -63,11 +60,8 @@ public enum DatabaseQuery {
|
|||
SCORE("SELECT score FROM completions WHERE fk_player = ? AND fk_puzzle = ?"),
|
||||
SCORE_GROUP("SELECT c.score\r\n"
|
||||
+ "FROM completions c\r\n"
|
||||
+ "JOIN containsGroups cG on c.fk_player = cG.fk_player\r\n"
|
||||
+ "JOIN groups g on cG.fk_group = g.id_group\r\n"
|
||||
+ "JOIN puzzles p on p.id_puzzle = c.fk_puzzle\r\n"
|
||||
+ "JOIN chapters ch on ch.id_chapter = p.fk_chapter\r\n"
|
||||
+ "WHERE (ch.id_chapter = 12) AND cG.fk_player = ? AND p.id_puzzle = ?"),
|
||||
+ "WHERE c.fk_puzzle = ? AND c.fk_player IN\r\n"
|
||||
+ "(select f.fk_player FROM containsGroups cgs JOIN containsGroups f ON f.fk_group = cgs.fk_group JOIN groups g ON g.id_group = cgs.fk_group WHERE g.fk_chapter = 12 AND cgs.fk_player = ?)"),
|
||||
|
||||
// PLAYERS
|
||||
GET_PLAYER_SIMPLE("SELECT pseudo, email, firstname, lastname, description FROM players WHERE id_player = ?"),
|
||||
|
|
|
@ -157,8 +157,8 @@ public class DatabaseRepository {
|
|||
try {
|
||||
ensureConnection();
|
||||
PreparedStatement stmt = DatabaseQuery.SCORE_GROUP.prepare(this.con);
|
||||
stmt.setInt(1, user);
|
||||
stmt.setInt(2, puzzle);
|
||||
stmt.setInt(1, puzzle);
|
||||
stmt.setInt(2, user);
|
||||
ResultSet result = stmt.executeQuery();
|
||||
if (result.next())
|
||||
return result.getInt("score");
|
||||
|
@ -179,8 +179,8 @@ public class DatabaseRepository {
|
|||
public Completion getCompletionGroup(int user, int puzzle) {
|
||||
try {
|
||||
PreparedStatement stmt = DatabaseQuery.GET_COMPLETION_GROUP.prepare(this.con);
|
||||
stmt.setInt(1, user);
|
||||
stmt.setInt(2, puzzle);
|
||||
stmt.setInt(1, puzzle);
|
||||
stmt.setInt(2, user);
|
||||
ResultSet result = stmt.executeQuery();
|
||||
if (result.next())
|
||||
return makeCompletion(result);
|
||||
|
|
Loading…
Add table
Reference in a new issue