get_project_statistics
Retrieve comprehensive project statistics and performance metrics for WeWork project management by providing a project ID.
Instructions
Lấy thống kê tổng quan về dự án
Args:
project_id: ID của dự án
Returns:
Thống kê chi tiết về dự án
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes |
Implementation Reference
- wework_mcp_server.py:256-327 (handler)The primary handler function for the 'get_project_statistics' MCP tool, decorated with @mcp.tool() for automatic registration. It computes comprehensive project statistics by fetching project info and task analysis data from the WeWorkClient, calculating metrics such as total tasks, status breakdown, assignee distribution, task types, and completion rate.@mcp.tool() def get_project_statistics(project_id: str) -> Dict[str, Any]: """ Lấy thống kê tổng quan về dự án Args: project_id: ID của dự án Returns: Thống kê chi tiết về dự án """ try: if not wework_client: return {'error': 'WeWork client not initialized'} logger.info(f"Getting statistics for project ID: {project_id}") # Lấy thông tin dự án project_info = wework_client.get_project_info(project_id) if not project_info: return { 'error': f'Không tìm thấy dự án với ID: {project_id}', 'success': False } # Phân tích tasks df = wework_client.get_project_analysis(project_id) if df.empty: return { 'success': True, 'project_name': project_info['name'], 'project_id': project_id, 'statistics': { 'total_tasks': 0, 'task_breakdown': {}, 'assignee_breakdown': {}, 'completion_rate': 0 } } # Tính các thống kê với kiểm tra column tồn tại total_tasks = len(df) status_counts = df['Trạng thái'].value_counts().to_dict() if 'Trạng thái' in df.columns else {} assignee_counts = df['Người thực hiện'].value_counts().to_dict() if 'Người thực hiện' in df.columns else {} task_type_counts = df['Loại công việc'].value_counts().to_dict() if 'Loại công việc' in df.columns else {} # Tính completion rate completed = status_counts.get('Hoàn thành', 0) completion_rate = (completed / total_tasks * 100) if total_tasks > 0 else 0 return { 'success': True, 'project_name': project_info['name'], 'project_id': project_id, 'statistics': { 'total_tasks': total_tasks, 'task_breakdown': status_counts, 'assignee_breakdown': assignee_counts, 'task_type_breakdown': task_type_counts, 'completion_rate': round(completion_rate, 2), 'summary': { 'completed': status_counts.get('Hoàn thành', 0), 'in_progress': status_counts.get('Đang thực hiện', 0), 'failed': status_counts.get('Thất bại', 0) } } } except Exception as e: logger.error(f"Error in get_project_statistics: {e}") return {'error': str(e), 'success': False}