Spaces:
Runtime error
Runtime error
| import logging | |
| from typing import Dict, List | |
| class PerformanceAnalyzer: | |
| def __init__(self, db_connection): | |
| self.conn = db_connection | |
| def analyze_user_performance(self, user_id: str) -> Dict: | |
| try: | |
| cursor = self.conn.cursor() | |
| cursor.execute(''' | |
| SELECT topic, AVG(performance_score) as avg_score | |
| FROM study_progress | |
| WHERE user_id = ? | |
| GROUP BY topic | |
| ''', (user_id,)) | |
| return dict(cursor.fetchall()) | |
| except Exception as e: | |
| logging.error(f"Erro ao analisar performance: {e}") | |
| return {} | |
| def get_weak_areas(self, user_id: str) -> List[str]: | |
| try: | |
| cursor = self.conn.cursor() | |
| cursor.execute(''' | |
| SELECT topic | |
| FROM study_progress | |
| WHERE user_id = ? AND performance_score < 70 | |
| GROUP BY topic | |
| ''', (user_id,)) | |
| return [row[0] for row in cursor.fetchall()] | |
| except Exception as e: | |
| logging.error(f"Erro ao buscar áreas fracas: {e}") | |
| return [] |