From 333ae47d8c4e8aae2dc5f05d22a0462281e74366 Mon Sep 17 00:00:00 2001 From: yvonne Date: Mon, 8 Dec 2025 19:32:20 +0100 Subject: [PATCH 1/2] introduce bug --- app/main.py | 2 +- trainings-tasks/00_prerequists_intro.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index fecf5e2..15621fa 100644 --- a/app/main.py +++ b/app/main.py @@ -61,7 +61,7 @@ async def generate_productivity_report() -> ProductivityReport: app = FastAPI(title="Productivity Reporting System") @app.get("/status") -def get_status(): +def get_status() return {"status": "ok"} diff --git a/trainings-tasks/00_prerequists_intro.md b/trainings-tasks/00_prerequists_intro.md index 7792be2..cbe6fe4 100644 --- a/trainings-tasks/00_prerequists_intro.md +++ b/trainings-tasks/00_prerequists_intro.md @@ -19,7 +19,7 @@ To ensure a smooth session, please ensure the following items are verified befor - **Visual Studio Code**: Recommended to use latest stable VS Code. - **Required Extensions**: Install the [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) and [GitHub Pull Requests & Issues](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extensions in VS Code. - **`uv` Package Manager**: The `uv` utility is required for fast environment and dependency management: [uv Installation Guide](https://docs.astral.sh/uv/getting-started/installation/) -- **Code Base**: Fork the [course repository](https://github.com/YvFrey/training-github-copilot/tree/main) to your own GitHub account. Clone **your project** locally. This setup ensures you have all necessary permissions in Github when running your custom agents. +- **Code Base**: Fork the [course repository](https://github.com/YvFrey/github-copilot-training.git) to your own GitHub account. Clone **your project** locally. This setup ensures you have all necessary permissions in Github when running your custom agents. ### ⚠️ Important: Feature Alignment and Version Check From a8a25a462df2500dadf165b32ef3ac3855fbb99d Mon Sep 17 00:00:00 2001 From: epoes Date: Tue, 21 Apr 2026 15:16:47 +0200 Subject: [PATCH 2/2] refactor: reorganize code structure and improve task status logic --- app/main.py | 42 +++++++++++++++--------------------------- app/models.py | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 app/models.py diff --git a/app/main.py b/app/main.py index 15621fa..eefefb9 100644 --- a/app/main.py +++ b/app/main.py @@ -1,29 +1,8 @@ -from typing import Dict +from typing import Dict, List import asyncio -from enum import Enum -from typing import List from fastapi import FastAPI -from pydantic import BaseModel -class TaskStatus(str, Enum): - """Available statuses for any task.""" - PENDING = "pending" - IN_PROGRESS = "in_progress" - COMPLETE = "complete" - -class DeveloperTask(BaseModel): - """Model for a single task logged by a developer.""" - task_id: int - title: str - status: TaskStatus = TaskStatus.PENDING - hours_spent: float = 0.0 - -class ProductivityReport(BaseModel): - """The final calculated report.""" - total_tasks: int - completed_tasks: int - total_hours_spent: float - completion_rate: float +from app.models import TaskStatus, DeveloperTask, ProductivityReport # --- Mock Database / In-Memory Service Logic @@ -44,7 +23,7 @@ async def generate_productivity_report() -> ProductivityReport: tasks = await fetch_all_tasks() total_tasks = len(tasks) - completed_tasks = sum(1 for task in tasks if task.status == TaskStatus.PENDING) + completed_tasks = sum(1 for task in tasks if task.status == TaskStatus.COMPLETE) total_hours_spent = sum(task.hours_spent for task in tasks) completion_rate = round(completed_tasks / total_tasks, 2) if total_tasks > 0 else 0.0 @@ -61,7 +40,7 @@ async def generate_productivity_report() -> ProductivityReport: app = FastAPI(title="Productivity Reporting System") @app.get("/status") -def get_status() +async def get_status() -> Dict: return {"status": "ok"} @@ -78,9 +57,18 @@ async def get_productivity_report(): @app.post("/log_task") -async def log_task(task: DeveloperTask): +async def log_task(task: DeveloperTask) -> Dict: new_id = max(MOCK_TASKS.keys()) + 1 if MOCK_TASKS else 1 task.task_id = new_id MOCK_TASKS[new_id] = task - return f"Task ID {task.task_id} logged successfully." + return {"task_id": task.task_id, "message": "Task logged successfully."} + +@app.get("/task/{task_id}/status") +async def get_task_status(task_id: int) -> Dict: + """Returns the status of a specific task by its ID.""" + task = MOCK_TASKS.get(task_id) + if not task: + return {"error": "Task not found."} + + return {"task_id": task_id, "status": task.status} \ No newline at end of file diff --git a/app/models.py b/app/models.py new file mode 100644 index 0000000..5c60f21 --- /dev/null +++ b/app/models.py @@ -0,0 +1,27 @@ +"""Pydantic data models for the FastAPI application.""" + +from enum import Enum +from pydantic import BaseModel + + +class TaskStatus(str, Enum): + """Available statuses for any task.""" + PENDING = "pending" + IN_PROGRESS = "in_progress" + COMPLETE = "complete" + + +class DeveloperTask(BaseModel): + """Model for a single task logged by a developer.""" + task_id: int + title: str + status: TaskStatus = TaskStatus.PENDING + hours_spent: float = 0.0 + + +class ProductivityReport(BaseModel): + """The final calculated report.""" + total_tasks: int + completed_tasks: int + total_hours_spent: float + completion_rate: float \ No newline at end of file