Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 15 additions & 27 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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"}


Expand All @@ -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}
27 changes: 27 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion trainings-tasks/00_prerequists_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down