aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorLoek Le Blansch <32883851+lonkaars@users.noreply.github.com>2021-04-23 10:20:23 +0200
committerGitHub <noreply@github.com>2021-04-23 10:20:23 +0200
commit0fcd48f49ba9cc80d63a2d24491881f46b9e3cd9 (patch)
tree710f461a1c4bc65f44804a44ce4bad3261c31bc8 /api
parent555f1ffa454865b9d6126cbff264766b92d7301e (diff)
parent6c1e9bd961eeee57828492a21f478675e15cb9aa (diff)
Merge pull request #17 from LarsV04/master
close #15
Diffstat (limited to 'api')
-rw-r--r--api/rating.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/api/rating.py b/api/rating.py
index cfdf5e4..17d52a2 100644
--- a/api/rating.py
+++ b/api/rating.py
@@ -1,4 +1,5 @@
from db import cursor
+from ruleset import resolve_ruleset
def outcome(outcome_str, player_1):
@@ -12,7 +13,7 @@ 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 " + \
+ 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()
@@ -29,6 +30,11 @@ def get_rating(user_id):
]
counted_opponents = {}
for game in mapped_games:
+ ruleset = resolve_ruleset(game[3])
+
+ if ruleset.ranked == False:
+ continue
+
# calculate sum score against user (+1 for win, -1 for lose, 0 for draw game)
counted_opponents[game[1]] = (counted_opponents.get(game[1]) or 0) + {
"w": 1,