Skip to content

Commit

Permalink
Fixing ObjectId issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Grexiem committed Dec 10, 2024
1 parent 783f91a commit 044e569
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def score(player, id):
if request.method == "GET":
score = get_score_player(player, blindtest_db["players"])
for bt in score:
if bt["id"] == id:
if str(bt["_id"]) == id:
return jsonify({"score": bt["score"]})
return jsonify({"score": 0})
if request.method == "POST":
Expand Down
6 changes: 3 additions & 3 deletions api/bt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ def blindtest(id, round, bt_db):


def get_blindtest(id_blindtest, bt_db):
query = {"_id": id_blindtest}
query = {"_id": ObjectId(id_blindtest)}
result = bt_db.find_one(query)
return result


def get_score_bt(id_blindtest, bt_db):
query = {"_id": id_blindtest}
query = {"_id": ObjectId(id_blindtest)}
result = bt_db.find_one(query)
return result["score"]


def change_score_bt(player, score, id_blindtest, bt_db):
query = {"_id": id_blindtest}
query = {"_id": ObjectId(id_blindtest)}
result = bt_db.find_one(query)
update_query = {"$set": {player: score}}
if result == None:
Expand Down
1 change: 1 addition & 0 deletions api/player.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from bson import ObjectId
import pymongo

folder_player = "../players/"
Expand Down

0 comments on commit 044e569

Please sign in to comment.