-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
365 additions
and
26 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
resources/migrations/20240819225346-add-guess-override.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE guesses | ||
DROP COLUMN overridden; |
2 changes: 2 additions & 0 deletions
2
resources/migrations/20240819225346-add-guess-override.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE guesses | ||
ADD COLUMN overridden boolean NOT NULL DEFAULT FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
-- :name insert-guess :! :n | ||
INSERT INTO guesses (clue_id, player_id, guess, correct, guessed_at) | ||
VALUES (:clue-id, :player-id, :guess, :correct, :guessed-at); | ||
|
||
-- :name get-guess :? :1 | ||
SELECT | ||
p.name as player, | ||
g.correct | ||
FROM guesses AS g | ||
JOIN players AS p ON g.player_id = p.id | ||
WHERE g.id = :id; | ||
|
||
-- :name get-current-guesses :? | ||
SELECT | ||
g.id, | ||
g.guess, | ||
p.id as player_id, | ||
p.name as player, | ||
g.correct, | ||
g.overridden | ||
FROM guesses AS g | ||
JOIN players AS p ON g.player_id = p.id | ||
WHERE g.clue_id = ( | ||
SELECT id FROM endless_clues | ||
WHERE game_id = :game-id | ||
ORDER BY id DESC | ||
LIMIT 1 | ||
) | ||
ORDER BY g.id; | ||
|
||
-- :name override-guess :! :n | ||
UPDATE guesses | ||
SET overridden = TRUE | ||
WHERE id = :id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.