Spaces:
Sleeping
Sleeping
Commit ·
40821e9
1
Parent(s): 852feb6
fixed calculations + puzzle
Browse files
app.py
CHANGED
|
@@ -324,6 +324,7 @@ def analyze_games(username, pgn_file):
|
|
| 324 |
|
| 325 |
opening_stats[opening]['total'] += 1
|
| 326 |
|
|
|
|
| 327 |
if user_result == 'win':
|
| 328 |
opening_stats[opening]['wins'] += 1
|
| 329 |
color_key = 'white' if user_color == chess.WHITE else 'black'
|
|
@@ -390,19 +391,31 @@ def analyze_games(username, pgn_file):
|
|
| 390 |
# Fetch puzzles
|
| 391 |
puzzles = fetch_lichess_puzzles(5)
|
| 392 |
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
"
|
| 400 |
-
|
| 401 |
-
""
|
| 402 |
-
|
| 403 |
-
""
|
| 404 |
-
|
| 405 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
|
| 407 |
puzzle_svgs = []
|
| 408 |
puzzle_info = []
|
|
|
|
| 324 |
|
| 325 |
opening_stats[opening]['total'] += 1
|
| 326 |
|
| 327 |
+
# Fix: Only increment win/loss/draw if user_result is not None
|
| 328 |
if user_result == 'win':
|
| 329 |
opening_stats[opening]['wins'] += 1
|
| 330 |
color_key = 'white' if user_color == chess.WHITE else 'black'
|
|
|
|
| 391 |
# Fetch puzzles
|
| 392 |
puzzles = fetch_lichess_puzzles(5)
|
| 393 |
|
| 394 |
+
# Fix: Format puzzle output as requested
|
| 395 |
+
puzzle_text = "## 🧩 Sizning shaxsiy masalalaringiz\n\n"
|
| 396 |
+
if puzzles:
|
| 397 |
+
for i, puzzle in enumerate(puzzles, 1):
|
| 398 |
+
theme = puzzle.get('themes', ['Tactics'])[0].title() if 'themes' in puzzle else 'Tactics'
|
| 399 |
+
rating = puzzle.get('rating', 1500)
|
| 400 |
+
url = f"https://lichess.org/training/{puzzle.get('id', '')}"
|
| 401 |
+
fen = puzzle.get('fen', '')[:40]
|
| 402 |
+
puzzle_text += f"**Puzzle {i}: {theme}** (Rating: {rating})\n"
|
| 403 |
+
puzzle_text += f"- [Solve on Lichess]({url})\n"
|
| 404 |
+
puzzle_text += f"- Position: `{fen}...`\n\n"
|
| 405 |
+
else:
|
| 406 |
+
puzzle_text += "- Masalalarni [Lichess.org](https://lichess.org/training) saytidan ishlang\n"
|
| 407 |
+
|
| 408 |
+
return (
|
| 409 |
+
full_report,
|
| 410 |
+
ai_report,
|
| 411 |
+
puzzle_text,
|
| 412 |
+
"",
|
| 413 |
+
None,
|
| 414 |
+
"",
|
| 415 |
+
None,
|
| 416 |
+
"",
|
| 417 |
+
None
|
| 418 |
+
)
|
| 419 |
|
| 420 |
puzzle_svgs = []
|
| 421 |
puzzle_info = []
|