MrSimple07 commited on
Commit
627aad0
Β·
1 Parent(s): 19ccaae

some more fixing text and 5 most weaknesses

Browse files
Files changed (1) hide show
  1. core/core.py +8 -4
core/core.py CHANGED
@@ -3,11 +3,14 @@ import chess
3
  import chess.pgn
4
  import io
5
  import re
 
6
  from collections import defaultdict
7
  from core.ai_integration import get_comprehensive_analysis
8
  from core.openings import detect_opening, load_opening_database
9
  from core.chess_api import get_user_games_from_chess_com, fetch_lichess_puzzles
10
 
 
 
11
  def extract_user_rating(games, username):
12
  ratings = []
13
  username_lower = username.strip().lower()
@@ -70,6 +73,7 @@ def analyze_games(username_chesscom, pgn_file, username_pgn):
70
 
71
  # Extract user rating from games
72
  user_rating = extract_user_rating(games, actual_username)
 
73
 
74
  all_analyses = []
75
  opening_stats = defaultdict(lambda: {'wins': 0, 'losses': 0, 'draws': 0, 'total': 0})
@@ -109,12 +113,12 @@ def analyze_games(username_chesscom, pgn_file, username_pgn):
109
  all_mistakes.extend(analysis.get('mistakes', []))
110
 
111
  stats_report = f"## πŸ“Š {len(games)} ta o'yin tahlili\n\n"
112
- stats_report += f"**Sizning reytingingiz:** {user_rating}\n"
113
  stats_report += f"**Jami xatolar:** {len(all_mistakes)} ta\n\n"
114
 
115
- stats_report += "### 🎯 Eng zaif 3 tomoningiz:\n\n"
116
  if weaknesses:
117
- for i, w in enumerate(weaknesses[:3], 1):
118
  stats_report += f"**{i}. {w['category']}** - {w['count']} marta ({w['percentage']:.1f}%)\n"
119
  else:
120
  stats_report += "Xatolar topilmadi yoki tahlil qilinmadi.\n"
@@ -156,7 +160,7 @@ def analyze_games(username_chesscom, pgn_file, username_pgn):
156
  ai_analysis = get_comprehensive_analysis(weaknesses, opening_stats, color_stats, len(games))
157
  ai_report = f"## πŸ€– AI Murabbiy: To'liq Tahlil va O'quv Rejasi\n\n{ai_analysis}"
158
 
159
- weakness_themes = [w['category'] for w in weaknesses[:3]]
160
  puzzles = fetch_lichess_puzzles(weakness_themes, user_rating=user_rating, count=5)
161
 
162
  puzzle_text = "## 🧩 Sizning shaxsiy masalalaringiz\n\n"
 
3
  import chess.pgn
4
  import io
5
  import re
6
+ import logging
7
  from collections import defaultdict
8
  from core.ai_integration import get_comprehensive_analysis
9
  from core.openings import detect_opening, load_opening_database
10
  from core.chess_api import get_user_games_from_chess_com, fetch_lichess_puzzles
11
 
12
+ logger = logging.getLogger(__name__)
13
+
14
  def extract_user_rating(games, username):
15
  ratings = []
16
  username_lower = username.strip().lower()
 
73
 
74
  # Extract user rating from games
75
  user_rating = extract_user_rating(games, actual_username)
76
+ logger.info(f"Extracted user rating: {user_rating}")
77
 
78
  all_analyses = []
79
  opening_stats = defaultdict(lambda: {'wins': 0, 'losses': 0, 'draws': 0, 'total': 0})
 
113
  all_mistakes.extend(analysis.get('mistakes', []))
114
 
115
  stats_report = f"## πŸ“Š {len(games)} ta o'yin tahlili\n\n"
116
+ stats_report += f"**Sizning o'rtacha reytingingiz:** {user_rating}\n\n"
117
  stats_report += f"**Jami xatolar:** {len(all_mistakes)} ta\n\n"
118
 
119
+ stats_report += "### 🎯 Eng zaif 5 tomoningiz:\n\n"
120
  if weaknesses:
121
+ for i, w in enumerate(weaknesses[:5], 1):
122
  stats_report += f"**{i}. {w['category']}** - {w['count']} marta ({w['percentage']:.1f}%)\n"
123
  else:
124
  stats_report += "Xatolar topilmadi yoki tahlil qilinmadi.\n"
 
160
  ai_analysis = get_comprehensive_analysis(weaknesses, opening_stats, color_stats, len(games))
161
  ai_report = f"## πŸ€– AI Murabbiy: To'liq Tahlil va O'quv Rejasi\n\n{ai_analysis}"
162
 
163
+ weakness_themes = [w['category'] for w in weaknesses[:5]]
164
  puzzles = fetch_lichess_puzzles(weakness_themes, user_rating=user_rating, count=5)
165
 
166
  puzzle_text = "## 🧩 Sizning shaxsiy masalalaringiz\n\n"