playtime nigga

This commit is contained in:
solis 2019-01-02 21:31:28 +10:30 committed by GitHub
parent 4bed475351
commit 560af3ef8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,22 @@ from common.ripple import passwordUtils, scoreUtils
from objects import glob
def getBeatmapTime(beatmapID):
p = 0
r = requests.get("http://cg.mxr.lol/api/b/{}".format(beatmapID)).text
if r != "null\n":
p = json.loads(r)['TotalLength']
return p
def incrementPlaytime(userID, gameMode=0, length=0):
modeForDB = gameModes.getGameModeForDB(gameMode)
result = glob.db.fetch("SELECT playtime_{gm} as playtime FROM users_stats WHERE id = %s".format(gm=modeForDB), [userID])
if result is not None:
glob.db.execute("UPDATE users_stats SET playtime_{gm} = %s WHERE id = %s".format(gm=modeForDB), [(int(result['playtime'])+int(length)), userID])
else:
print("something went wrong...")
def getUserStats(userID, gameMode):
"""
Get all user stats relative to `gameMode`