Fix issue where hint with a free requirement could not be unlocked (#2107)

* Fix issue where hint with a free requirement could not be unlocked

* Fix issue with referring to the right hint id
This commit is contained in:
Kevin Chung
2022-05-03 04:37:03 -04:00
committed by GitHub
parent f3e43d97a6
commit 4369272c49

View File

@@ -125,7 +125,14 @@ class Hint(Resource):
# Get the IDs of all hints that the user has unlocked # Get the IDs of all hints that the user has unlocked
all_unlocks = HintUnlocks.query.filter_by(account_id=user.account_id).all() all_unlocks = HintUnlocks.query.filter_by(account_id=user.account_id).all()
unlock_ids = {unlock.id for unlock in all_unlocks} unlock_ids = {unlock.target for unlock in all_unlocks}
# Get the IDs of all free hints
free_hints = Hints.query.filter_by(cost=0).all()
free_ids = {h.id for h in free_hints}
# Add free hints to unlocked IDs
unlock_ids.update(free_ids)
# Filter out hint IDs that don't exist # Filter out hint IDs that don't exist
all_hint_ids = {h.id for h in Hints.query.with_entities(Hints.id).all()} all_hint_ids = {h.id for h in Hints.query.with_entities(Hints.id).all()}