Skip to content

Commit

Permalink
Merge pull request #4 from achannn/achannn/3_prevent-duplicate-game-i…
Browse files Browse the repository at this point in the history
…n-question

#3: Prevent duplicate games from appearing in question
  • Loading branch information
komali2 authored Feb 5, 2024
2 parents 6cee68b + 67170e6 commit 7e18cdd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ def create_question(db: Session,
return question

def generate_question(db: Session):
questions = db.query(models.Remix).order_by(func.random()).limit(4)
games = db.query(models.Videogame).order_by(func.random()).limit(4)
questions = (db.query(models.Remix)
.join(models.OriginalSong)
.join(games)
.distinct(models.OriginalSong.original_song_videogame_id)
.order_by(models.OriginalSong.original_song_videogame_id, func.random()))
internal.log_error(questions)
response = construct_frontend_question(questions)
return response
Expand Down

0 comments on commit 7e18cdd

Please sign in to comment.