aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/auth/signup.py5
-rw-r--r--api/rating.py17
-rw-r--r--api/readme.md3
3 files changed, 15 insertions, 10 deletions
diff --git a/api/auth/signup.py b/api/auth/signup.py
index 571adb4..180322a 100644
--- a/api/auth/signup.py
+++ b/api/auth/signup.py
@@ -70,7 +70,10 @@ def index():
# write new user to database and commit
cursor.execute(
"insert into users values (?, ?, ?, NULL, NULL, ?, ?, \"[]\", FALSE, \"user\", \"{}\", ?) ",
- (user_id, username, email, password_hash, registered, bcrypt.gensalt())
+ (
+ user_id, username, email, password_hash, registered,
+ bcrypt.gensalt()
+ )
)
connection.commit()
diff --git a/api/rating.py b/api/rating.py
index 17d52a2..11fc2f4 100644
--- a/api/rating.py
+++ b/api/rating.py
@@ -14,20 +14,21 @@ def rating_v1(won_games): # python is a garbage language
def get_all_games(user_id):
return cursor.execute("select player_1_id, player_2_id, outcome, ruleset " + \
- "from games " + \
- "where (player_1_id = ? or player_2_id = ?) " + \
- "and status = \"finished\" or status = \"resign\"", [user_id, user_id]).fetchall()
+ "from games " + \
+ "where (player_1_id = ? or player_2_id = ?) " + \
+ "and status = \"finished\" or status = \"resign\"", [user_id, user_id]).fetchall()
-# simple rating function that doesn't use game analysis
+ # simple rating function that doesn't use game analysis
def get_rating(user_id):
score = 400
games = get_all_games(user_id)
# get all games for user_id and switch perspective in which user_id is player_2_id
mapped_games = [
game if game[0] == user_id else
- (game[1], game[0], outcome(game[2], False)) for game in games
+ (game[1], game[0], outcome(game[2], False), game[3]) for game in games
]
+
counted_opponents = {}
for game in mapped_games:
ruleset = resolve_ruleset(game[3])
@@ -41,7 +42,7 @@ def get_rating(user_id):
"l": -1,
"d": 0
}[game[2]]
- for opponent in counted_opponents:
- # apply the cool curve to the sum score and add to the base score of 400
- score += rating_v1(counted_opponents.get(opponent))
+ for opponent in counted_opponents:
+ # apply the cool curve to the sum score and add to the base score of 400
+ score += rating_v1(counted_opponents.get(opponent))
return int(score)
diff --git a/api/readme.md b/api/readme.md
index 669b53b..6d0da60 100644
--- a/api/readme.md
+++ b/api/readme.md
@@ -599,7 +599,8 @@ returns error when image is not .png or larger than 256x256
```ts
{
- code: string
+ code:
+ string;
}
```