148 lines
6.5 KiB
Markdown
148 lines
6.5 KiB
Markdown
---
|
|
phase: 49-automation-history-tab
|
|
plan: 01
|
|
subsystem: automation
|
|
tags: [automation, history, cron, tabs, update_order_status]
|
|
|
|
requires:
|
|
- phase: 47-shipment-created-automation
|
|
provides: automation trigger shipment.created i akcje automatyzacji
|
|
provides:
|
|
- historia wykonan automatyzacji z filtrami i paginacja
|
|
- retencja historii 30 dni przez cron cleanup
|
|
- akcja automatyzacji update_order_status
|
|
affects: [settings-automation, cron, automation-service]
|
|
|
|
tech-stack:
|
|
added: []
|
|
patterns: [execution-log-per-rule, tabbed-settings-view, safe-automation-action-validation]
|
|
|
|
key-files:
|
|
created:
|
|
- database/migrations/20260328_000072_create_automation_execution_logs_table.sql
|
|
- src/Modules/Automation/AutomationExecutionLogRepository.php
|
|
- src/Modules/Cron/AutomationHistoryCleanupHandler.php
|
|
modified:
|
|
- src/Modules/Automation/AutomationController.php
|
|
- src/Modules/Automation/AutomationRepository.php
|
|
- src/Modules/Automation/AutomationService.php
|
|
- resources/views/automation/index.php
|
|
- resources/views/automation/form.php
|
|
- public/assets/js/modules/automation-form.js
|
|
|
|
key-decisions:
|
|
- "Historia automatyzacji zapisywana per regula (success/failed) bez blokowania glownego flow"
|
|
- "Nowa akcja update_order_status korzysta z centralnego OrdersRepository::updateOrderStatus"
|
|
- "Retencja historii realizowana cronem automation_history_cleanup (30 dni)"
|
|
|
|
patterns-established:
|
|
- "Tab settings/history z zapamietywaniem aktywnej zakladki"
|
|
- "Walidacja configu akcji automatyzacji po stronie kontrolera"
|
|
|
|
duration: ~55min
|
|
started: 2026-03-28T13:50:03+01:00
|
|
completed: 2026-03-28T14:45:16+01:00
|
|
---
|
|
|
|
# Phase 49 Plan 01: Automation History + Update Order Status Summary
|
|
|
|
**Dostarczono rozdzielenie `/settings/automation` na `Ustawienia/Historia`, audyt historii wykonan regul i akcje `update_order_status`, a dodatkowo po testach wdrozono hotfix fallbacku daty pickup dla Apaczka.**
|
|
|
|
## Performance
|
|
|
|
| Metric | Value |
|
|
|--------|-------|
|
|
| Duration | ~55 min |
|
|
| Started | 2026-03-28T13:50:03+01:00 |
|
|
| Completed | 2026-03-28T14:45:16+01:00 |
|
|
| Tasks | 4 completed |
|
|
| Files modified | 16+ |
|
|
|
|
## Acceptance Criteria Results
|
|
|
|
| Criterion | Status | Notes |
|
|
|-----------|--------|-------|
|
|
| AC-1: Dwa taby na `/settings/automation` | Pass | `resources/views/automation/index.php` ma taby `Ustawienia` i `Historia` |
|
|
| AC-2: Log co/kiedy/jakie zamowienie | Pass | `AutomationService::logExecution()` + `automation_execution_logs` |
|
|
| AC-3: Filtry + paginacja historii | Pass | `AutomationController::index` + `AutomationExecutionLogRepository::paginate/count` |
|
|
| AC-4: Auto-usuwanie wpisow >30 dni | Pass | cron `automation_history_cleanup` + `purgeOlderThanDays()` |
|
|
| AC-5: Dokumentacja techniczna | Pass | zaktualizowane `DOCS/DB_SCHEMA.md`, `DOCS/ARCHITECTURE.md`, `DOCS/TECH_CHANGELOG.md` |
|
|
| AC-6: Akcja `update_order_status` | Pass | formularz + walidacja + wykonanie przez `OrdersRepository::updateOrderStatus` |
|
|
|
|
## Verification Results
|
|
|
|
- `C:\xampp\php\php.exe -l src/Modules/Automation/AutomationController.php` -> OK
|
|
- `C:\xampp\php\php.exe -l src/Modules/Automation/AutomationRepository.php` -> OK
|
|
- `C:\xampp\php\php.exe -l src/Modules/Automation/AutomationExecutionLogRepository.php` -> OK
|
|
- `C:\xampp\php\php.exe -l src/Modules/Automation/AutomationService.php` -> OK
|
|
- `C:\xampp\php\php.exe -l src/Modules/Cron/CronHandlerFactory.php` -> OK
|
|
- `C:\xampp\php\php.exe -l src/Modules/Cron/AutomationHistoryCleanupHandler.php` -> OK
|
|
- `C:\xampp\php\php.exe -l resources/views/automation/form.php` -> OK
|
|
- `C:\xampp\php\php.exe -l resources/views/automation/index.php` -> OK
|
|
- `sonar-scanner` uruchomiony pomyslnie (project `orderPRO`, dashboard updated)
|
|
|
|
## Files Created/Modified
|
|
|
|
| File | Change | Purpose |
|
|
|------|--------|---------|
|
|
| `database/migrations/20260328_000072_create_automation_execution_logs_table.sql` | Created | tabela historii + seed cleanup cron |
|
|
| `src/Modules/Automation/AutomationExecutionLogRepository.php` | Created | zapis/listowanie/paginacja/purge historii |
|
|
| `src/Modules/Cron/AutomationHistoryCleanupHandler.php` | Created | czyszczenie wpisow >30 dni |
|
|
| `src/Modules/Cron/CronHandlerFactory.php` | Modified | podpiety handler cleanup |
|
|
| `src/Modules/Automation/AutomationController.php` | Modified | backend tabu historii + nowa akcja update_order_status |
|
|
| `src/Modules/Automation/AutomationRepository.php` | Modified | sortowanie nazw regul + statusy zamowien do akcji |
|
|
| `src/Modules/Automation/AutomationService.php` | Modified | log execution + wykonanie update_order_status |
|
|
| `resources/views/automation/index.php` | Modified | taby, filtry i paginacja historii |
|
|
| `resources/views/automation/form.php` | Modified | UI akcji `Zmiana statusu zamowienia` |
|
|
| `public/assets/js/modules/automation-form.js` | Modified | dynamiczna obsluga nowej akcji |
|
|
| `DOCS/DB_SCHEMA.md` | Modified | kontrakt tabeli historii i zmiany flow |
|
|
| `DOCS/ARCHITECTURE.md` | Modified | opis nowego flow i akcji |
|
|
| `DOCS/TECH_CHANGELOG.md` | Modified | chronologia wdrozenia |
|
|
|
|
## Decisions Made
|
|
|
|
| Decision | Rationale | Impact |
|
|
|----------|-----------|--------|
|
|
| Log historii per regula (success/failed) | pelny audyt bez przerywania triggera | szybsza diagnostyka automatyzacji |
|
|
| `update_order_status` przez `OrdersRepository::updateOrderStatus` | reuse centralnego flow status history + activity log | brak duplikacji logiki i spojnosc domenowa |
|
|
| Cleanup historii jako cron | retencja bez manualnej obslugi | stabilny rozmiar danych |
|
|
|
|
## Deviations from Plan
|
|
|
|
### Summary
|
|
|
|
| Type | Count | Impact |
|
|
|------|-------|--------|
|
|
| Auto-fixed | 0 | None |
|
|
| Scope additions | 1 | Niski, uzasadniony produkcyjnym bledem |
|
|
| Deferred | 0 | None |
|
|
|
|
### Scope addition
|
|
|
|
- Po APPLY i testach produkcyjnych dodano hotfix `ApaczkaShipmentService`:
|
|
- fallback retry dla bledow niedostepnego dnia pickup (`Pickup not available...` oraz `you can't place an order today`),
|
|
- automatyczne przesuwanie `pickup.date` na kolejny dzien roboczy (max 7 prob).
|
|
- Powod: rzeczywisty blad operacyjny blokujacy tworzenie przesylek.
|
|
|
|
## Skill Audit
|
|
|
|
- Required `sonar-scanner`: invoked ✓
|
|
- Optional `/code-review`: not invoked
|
|
- Optional `/frontend-design`: not invoked
|
|
|
|
## Next Phase Readiness
|
|
|
|
**Ready:**
|
|
- Automatyzacja ma audytowalna historie z retencja.
|
|
- Reguly obsluguja automatyczna zmiane statusu zamowienia.
|
|
|
|
**Concerns:**
|
|
- Warto rozwazyc logowanie rowniez przypadkow `skipped` (warunki niespelnione), aby ulatwic debug bez diagnostyki DB.
|
|
|
|
**Blockers:**
|
|
- None
|
|
|
|
---
|
|
*Phase: 49-automation-history-tab, Plan: 01*
|
|
*Completed: 2026-03-28*
|