Files
python-learning/projects/incident-tracker/README.md
T
2026-12-02 16:58:44 +01:00

22 lines
1.3 KiB
Markdown

# Capstone Mini-Projekt: `incident-tracker` (CLI + SQLite + JSON logs)
Ten sam projekt SRE realizujesz w Pythonie, Go i Ruście, żeby porównać ergonomię i architekturę wszystkich trzech języków.
## Wymagania
Zaimplementuj aplikację `incident-tracker` (`tracker.py`):
1. **Model domenowy:** `Incident(id, title, severity, status)` gdzie `severity` ∈ `{"low", "medium", "high", "critical"}`, `status` ∈ `{"open", "resolved"}`.
2. **Warstwa persystencji (`IncidentStore` na SQLite):**
* `init_schema()` — idempotentne tworzenie tabeli `incidents`.
* `add(title: str, severity: str) -> Incident` — walidacja niepustego tytułu i dozwolonego `severity`, zapis przez parametryzowane zapytanie.
* `list_incidents(severity: str | None = None) -> list[Incident]` — opcjonalne filtrowanie.
* `resolve(incident_id: int) -> Incident` — zmiana statusu na `"resolved"` (lub `IncidentNotFoundError`).
* `stats() -> dict[str, int]` — zliczenie incydentów po `status` (`{"open": ..., "resolved": ...}`).
3. **Warstwa CLI (`build_cli(db_path: Path)` w `typer`):**
* Podkomendy: `add <title> --severity <sev>`, `list [--severity <sev>]`, `resolve <id>`, `stats`.
* Wynik wypisywany jako czysty JSON na `stdout`.
## Uruchomienie testów
```bash
make test-project
```