mirror of
https://github.com/FAUSheppy/skillbird
synced 2025-12-06 06:51:34 +01:00
add player rank to player query
This commit is contained in:
@@ -23,6 +23,17 @@ def getPlayer(playerId):
|
|||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
def getPlayerRank(player):
|
||||||
|
'''Get a players current rank, seperate function because this query is relatively expensive'''
|
||||||
|
|
||||||
|
conn = sqlite3.connect("players.sqlite")
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("SELECT COUNT(*) from players where (mu-2*sigma) > (?-2*?);",
|
||||||
|
(player.rating.mu, player.rating.sigma))
|
||||||
|
rank = cursor.fetchone()[0]
|
||||||
|
conn.close()
|
||||||
|
return rank
|
||||||
|
|
||||||
def getOrCreatePlayer(player):
|
def getOrCreatePlayer(player):
|
||||||
playerInDb = getPlayer(player.id)
|
playerInDb = getPlayer(player.id)
|
||||||
if not playerInDb:
|
if not playerInDb:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def getPlayer():
|
|||||||
p = db.getPlayer(playerId)
|
p = db.getPlayer(playerId)
|
||||||
if not p:
|
if not p:
|
||||||
return ("Player not found", 404)
|
return ("Player not found", 404)
|
||||||
return "{}'s Rating: {}".format(p.name, int(p.rating.mu - 2*p.rating.sigma))
|
return "{}'s Rating: {} (Rank {})".format(p.name, int(p.rating.mu - 2*p.rating.sigma), db.getPlayerRank(p))
|
||||||
|
|
||||||
@app.route('/get-outcome-prediction', methods=["POST"])
|
@app.route('/get-outcome-prediction', methods=["POST"])
|
||||||
def getOutcomePrediction():
|
def getOutcomePrediction():
|
||||||
|
|||||||
Reference in New Issue
Block a user