Skip to content

Commit

Permalink
chore: add count finished games to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioqfeg1 committed Apr 16, 2024
1 parent 6dc9fd9 commit 99690e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/src/main/java/lab/en2b/quizapi/game/GameRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ public interface GameRepository extends JpaRepository<Game,Long> {

@Query(value = "SELECT * FROM Games g WHERE user_id = ?1 AND g.is_game_over = false LIMIT 1", nativeQuery = true)
Optional<Game> findActiveGameForUser(Long userId);

@Query(value = "COUNT(*) FROM Games g WHERE user_id = ?1 AND g.is_game_over = true", nativeQuery = true)
Long countFinishedGamesForUser(Long userId);
}

0 comments on commit 99690e3

Please sign in to comment.