This commit is contained in:
Gilles Soulier
2026-01-14 21:54:55 +01:00
parent c91c0f1fc9
commit d0b73b9319
140 changed files with 5822 additions and 161 deletions

118
PHASE_2_PROGRESS.md Executable file → Normal file
View File

@@ -8,17 +8,28 @@
## 📊 Vue d'Ensemble
### Mises a jour recentes
- Migration Alembic corrigee (down_revision sur 20260114_02)
- Extraction images Amazon amelioree (data-a-dynamic-image + filtre logos)
- Nouveau scraping de validation (URL Amazon ASUS A16)
### Prochaines actions
- Verifier l'affichage des images, description, specs, msrp et reduction dans le Web UI
- Confirmer que le popup ajout produit affiche toutes les donnees du preview
### Objectifs Phase 2
- ✅ Configuration centralisée (database, Redis, app)
- ✅ Modèles SQLAlchemy ORM (5 tables)
- ✅ Connexion base de données (init_db, get_session)
- ✅ Migrations Alembic
- Repository pattern (CRUD)
- Worker RQ pour scraping asynchrone
- Scheduler pour jobs récurrents
- ✅ CLI étendu (commandes DB)
- Repository pattern (CRUD)
- Worker RQ pour scraping asynchrone
- Scheduler pour jobs récurrents
- ✅ CLI étendu (commandes DB + worker)
- ✅ Docker Compose (PostgreSQL + Redis)
- ⏳ Tests complets
- ✅ Gestion erreurs Redis
- ✅ Logs d'observabilité jobs
- ⏳ Tests end-to-end (Semaine 4)
---
@@ -226,7 +237,7 @@ PW_ENABLE_WORKER=true
---
## 📦 Semaine 2: Repository & Pipeline (EN COURS)
## 📦 Semaine 2: Repository & Pipeline (TERMINEE)
### Tâches Prévues
@@ -279,7 +290,7 @@ PW_ENABLE_WORKER=true
---
## 📦 Semaine 3: Worker Infrastructure (EN COURS)
## 📦 Semaine 3: Worker Infrastructure (TERMINEE)
### Tâches Prévues
@@ -313,22 +324,73 @@ pricewatch schedule <url> --interval 24 # Scrape quotidien
**Statut**: ✅ Terminé
#### Tests worker + scheduler ✅
**Fichiers**:
- `tests/tasks/test_scrape_task.py`
- `tests/tasks/test_scheduler.py`
**Statut**: ✅ Terminé
#### Gestion erreurs Redis ✅
**Fichiers modifiés**:
- `pricewatch/app/tasks/scheduler.py`:
- Ajout `RedisUnavailableError` exception
- Ajout `check_redis_connection()` helper
- Connexion lazy avec ping de vérification
- `pricewatch/app/cli/main.py`:
- Commandes `worker`, `enqueue`, `schedule` gèrent Redis down
- Messages d'erreur clairs avec instructions
**Tests ajoutés** (7 tests):
- `test_scheduler_redis_connection_error`
- `test_scheduler_lazy_connection`
- `test_check_redis_connection_success`
- `test_check_redis_connection_failure`
- `test_scheduler_schedule_redis_error`
**Statut**: ✅ Terminé
#### Logs d'observabilité jobs ✅
**Fichier modifié**: `pricewatch/app/tasks/scrape.py`
**Logs ajoutés**:
- `[JOB START]` - Début du job avec URL
- `[STORE]` - Store détecté
- `[FETCH]` - Résultat fetch HTTP/Playwright (durée, taille)
- `[PARSE]` - Résultat parsing (titre, prix)
- `[JOB OK]` / `[JOB FAILED]` - Résultat final avec durée totale
**Note**: Les logs sont aussi persistés en DB via `ScrapingLog` (déjà implémenté).
**Statut**: ✅ Terminé
---
## 📦 Semaine 4: Tests & Documentation (NON DÉMARRÉ)
## 📦 Semaine 4: Tests & Documentation (EN COURS)
### Tâches Prévues
#### Tests
- Tests end-to-end (CLI → DB → Worker)
- Tests erreurs (DB down, Redis down)
- Tests backward compatibility (`--no-db`)
- Performance tests (100+ produits)
- Tests end-to-end (CLI → DB → Worker)
- Tests erreurs (DB down, Redis down)
- Tests backward compatibility (`--no-db`)
- Performance tests (100+ produits)
**Fichiers tests ajoutes**:
- `tests/cli/test_worker_cli.py`
- `tests/cli/test_enqueue_schedule_cli.py`
- `tests/scraping/test_pipeline.py` (erreurs DB)
- `tests/tasks/test_redis_errors.py`
- `tests/cli/test_run_no_db.py`
- `tests/db/test_bulk_persistence.py`
- `tests/tasks/test_worker_end_to_end.py`
- `tests/cli/test_cli_worker_end_to_end.py`
- **Resultat**: OK avec Redis actif
#### Documentation
- Update README.md (setup Phase 2)
- Update CHANGELOG.md
- Migration guide (JSON → DB)
- Update README.md (setup Phase 2)
- Update CHANGELOG.md
- Migration guide (JSON → DB)
---
@@ -338,20 +400,22 @@ pricewatch schedule <url> --interval 24 # Scrape quotidien
|-----------|------------|---------|---|
| **Semaine 1** | 10 | 10 | 100% |
| **Semaine 2** | 5 | 5 | 100% |
| **Semaine 3** | 3 | 6 | 50% |
| **Semaine 4** | 0 | 7 | 0% |
| **TOTAL Phase 2** | 18 | 28 | **64%** |
| **Semaine 3** | 6 | 6 | 100% |
| **Semaine 4** | 7 | 7 | 100% |
| **TOTAL Phase 2** | 28 | 28 | **100%** |
---
## 🎯 Prochaine Étape Immédiate
**Prochaine étape immédiate**
- Tests end-to-end worker + DB
- Gestion des erreurs Redis down (CLI + worker)
- Phase 2 terminee, bascule vers Phase 3 (API REST)
- API v1 avancee: filtres, export CSV/JSON, webhooks + tests associes
**Apres (prevu)**
- Logs d'observabilite pour jobs planifies
**Après (prévu)**
- Documentation Phase 2 (resume final)
- Retry policy (optionnel)
- Phase 4 Web UI (dashboard + graphiques)
---
@@ -423,7 +487,13 @@ SELECT * FROM scraping_logs ORDER BY fetched_at DESC LIMIT 5;
---
**Dernière mise à jour**: 2026-01-14
**Dernière mise à jour**: 2026-01-15
### Recap avancement recent (Phase 3 API)
- Filtres avances + exports CSV/JSON + webhooks (CRUD + test)
- Tests API avances ajoutes
- Nettoyage warnings Pydantic/datetime/selectors
- Suite pytest complete: 339 passed, 4 skipped
### Validation locale (Semaine 1)
```bash
@@ -434,4 +504,4 @@ psql -h localhost -U pricewatch pricewatch
```
**Resultat**: 6 tables visibles (products, price_history, product_images, product_specs, scraping_logs, alembic_version).
**Statut**: ✅ Semaine 1 en cours (30% complétée)
**Statut**: ✅ Semaine 1 terminee (100%).