diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-10 14:37:12 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-10 14:37:12 +0100 |
commit | 1b8e3e479fb1fcea333571aaa3dd090ec78e346b (patch) | |
tree | 81e56c707a284f4e535ce947196dd0e8794924c0 /api | |
parent | ba0e25a47082ada94565da07b2451ff00d0e2857 (diff) |
/user page use /user/games api
Diffstat (limited to 'api')
-rw-r--r-- | api/api.ts | 27 | ||||
-rw-r--r-- | api/user/games.py | 4 |
2 files changed, 29 insertions, 2 deletions
@@ -31,3 +31,30 @@ export interface userPreferences { userColors?: userColors; } +export interface userGameTotals { + draw: number; + games: number; + lose: number; + win: number; +} + +export interface userGames { + totals: userGameTotals; + games: Array<gameInfo>; +} + +export interface gameInfo { + created: number; + duration: number; + id: string; + moves: Array<number>; + opponent: string; + outcome: "w"|"l"|"d"; + parent?: string; + private: boolean; + rating?: number; + rating_opponent?: number; + ruleset: ruleset; + started: number; + status: "finished"|"in_progress"|"resign"|"wait_for_opponent"; +} diff --git a/api/user/games.py b/api/user/games.py index f08928a..43bd59e 100644 --- a/api/user/games.py +++ b/api/user/games.py @@ -29,7 +29,7 @@ def game_info(game_id, user_id = None): return { "id": game[0], "parent": game[1], - "moves": game[2], + "moves": [int(column) for move in str(game[2]).split(",")], "opponent": game[3] if is_player_1 else game[4], "outcome": outcome, "created": game[6], @@ -39,7 +39,7 @@ def game_info(game_id, user_id = None): "rating_opponent": game[10] if is_player_1 else game[9], "ruleset": resolve_ruleset(game[11]), "status": game[12], - "private": game[13], + "private": bool(game[13]), } def sum_games(user_id): #! SANITIZE USER_ID FIRST |