Ejemplo n.º 1
0
def get_user_stats(username):
    db = sqlite3.connect(db_name)
    c = db.cursor()
    username = username.replace("'", "''")
    command = "SELECT username, pfp, best_img_id, worst_img_id, guesser_score, artist_score FROM users WHERE username = '******';" % username
    c.execute(command)
    user_as_tuple = c.fetchone()
    number_drawings = len(c.execute("SELECT id FROM drawings WHERE username = '******';" % username).fetchall())
    db.close()
    if user_as_tuple != None:
        user_stats = tuple_to_dictionary(user_as_tuple, ["username", "pfp", "best_image", "worst_image", "guesser_score", "artist_score"])
        user_stats["best_image"] = draw.get_image(user_stats["best_image"])
        user_stats["worst_image"] = draw.get_image(user_stats["worst_image"])
        user_stats["number_drawings"] = number_drawings
        return user_stats
    return {}
Ejemplo n.º 2
0
def get_guess(username, drawing_id):
    for guess in draw.get_image(drawing_id)["guesses"]:
        if guess["username"] == username:
            return guess["guess"]
    return None
Ejemplo n.º 3
0
def get_answer(drawing_id):
    return draw.get_image(drawing_id)["word"]
Ejemplo n.º 4
0
def who_guessed_it(drawing_id):
    return draw.get_image(drawing_id)["guesses"][-1]["username"]
Ejemplo n.º 5
0
def get_num_guesses(drawing_id):
    image = draw.get_image(drawing_id)
    if image["solved"] == True:
        return len(image["guesses"]) - 1
    return len(image["guesses"])
Ejemplo n.º 6
0
def get_artist(drawing_id):
    return draw.get_image(drawing_id)["artist"]