From a01ddac84b6f6a6016d39016f8fd39834ed985e8 Mon Sep 17 00:00:00 2001 From: Tanishq Singh Date: Thu, 1 Aug 2024 08:49:24 +0530 Subject: [PATCH] almost done --- .github/workflows/update_chess.yml | 2 +- render/history.py | 2 +- render/moves.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_chess.yml b/.github/workflows/update_chess.yml index bd830da..6cd0fda 100644 --- a/.github/workflows/update_chess.yml +++ b/.github/workflows/update_chess.yml @@ -80,7 +80,7 @@ jobs: game_status=$(python3 logic/check_game_status.py "$game_fen") jq --arg a "$game_fen" --arg b "$game_status" '.current_game_fen = $a | .stats.current_game = $b' game.json > temp.json && mv temp.json game.json - jq --arg a "$username" --arg b "${move:0:2}" --arg c "${move:2}" --arg d "$datetime" -r '.moves_history |= [{"datetime": $d, "human": {"username": $a, "from": $b, "to": $c}}] + .[0:-1]' game.json > temp.json && mv temp.json game.json + jq --arg a "$username" --arg b "${move:0:2}" --arg c "${move:2}" --arg d "$datetime" -r '.moves_history |= if length >= 5 then [{"datetime": $d, "human": {"username": $a, "from": $b, "to": $c}}] + .[0:-1] else [{"datetime": $d, "human": {"username": $a, "from": $b, "to": $c}}] + .[0:] end' game.json > temp.json && mv temp.json game.json if [ "$game_status" == "stillon" ]; then echo "gameover=no" >> $GITHUB_OUTPUT diff --git a/render/history.py b/render/history.py index 7cc54d1..0fd7fa7 100644 --- a/render/history.py +++ b/render/history.py @@ -19,7 +19,7 @@ def list_to_markdown(history_list): stockfish_from = move['stockfish']['from'] stockfish_to = move['stockfish']['to'] - markdown.append(f'|{i + 1}|`{datetime_obj.strftime("%d/%m/%y")}` `{datetime_obj.strftime("%H:%M:%S")}`| | [`{username}`](https://github.com/{username})|`{username_from}`|`{username_to}`|`{stockfish_from}`|`{stockfish_to}`|') + markdown.append(f'|{i + 1}|`{datetime_obj.strftime("%d/%m/%y")}`, `{datetime_obj.strftime("%H:%M:%S")}`| | [`{username}`](https://github.com/{username})|`{username_from}`|`{username_to}`|`{stockfish_from}`|`{stockfish_to}`|') return markdown diff --git a/render/moves.py b/render/moves.py index 57da489..585ea8d 100644 --- a/render/moves.py +++ b/render/moves.py @@ -27,7 +27,7 @@ def list_to_markdown(move_list): for i in range(0, len(move_list[from_move])): to_move = move_list[from_move][i] - line += f"[{to_move}](https://github.com/tanishq-singh-2407/tanishq-singh-2407/issues/new?title=chess_move_{from_move}{to_move}&labels=make+move&body=Just+push+%27Submit+new+issue%27.+You+don%27t+need+to+do+anything+else.), " + line += f"[{to_move}](https://github.com/tanishq-singh-2407/readme-chess/issues/new?title=chess_move_{from_move}{to_move}&labels=make+move&body=Just+push+%27Submit+new+issue%27.+You+don%27t+need+to+do+anything+else.), " line = line[:-2] + " |" markdown_lines.append(line)