update
This commit is contained in:
122
.paul/phases/07-pre-expansion-fixes/07-01-SUMMARY.md
Normal file
122
.paul/phases/07-pre-expansion-fixes/07-01-SUMMARY.md
Normal file
@@ -0,0 +1,122 @@
|
||||
---
|
||||
phase: 07-pre-expansion-fixes
|
||||
plan: 01
|
||||
subsystem: database
|
||||
tags: [performance, n+1, sql-optimization, indexes, static-cache]
|
||||
|
||||
requires:
|
||||
- phase: 06-sonarqube-quality
|
||||
provides: OrdersRepository refactored (god class split)
|
||||
provides:
|
||||
- Aggregating LEFT JOINs replacing N+1 correlated subqueries in orders list
|
||||
- Static cache for information_schema check
|
||||
- Performance indexes on orders table
|
||||
affects: [07-02, 07-03, 07-04]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [aggregating-left-join, static-property-cache]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- database/migrations/20260314_000048_add_orders_performance_indexes.sql
|
||||
modified:
|
||||
- src/Modules/Orders/OrdersRepository.php
|
||||
|
||||
key-decisions:
|
||||
- "allegro_order_status_mappings index skipped — already has UNIQUE KEY on allegro_status_code"
|
||||
- "Migration date 20260314 (execution date, not plan date)"
|
||||
|
||||
patterns-established:
|
||||
- "Aggregating LEFT JOIN zamiast correlated subqueries dla countów/sum w listach"
|
||||
- "Static property cache dla information_schema lookups"
|
||||
|
||||
duration: ~8min
|
||||
started: 2026-03-14
|
||||
completed: 2026-03-14
|
||||
---
|
||||
|
||||
# Phase 7 Plan 01: Performance Fixes Summary
|
||||
|
||||
**Eliminacja N+1 subqueries w liście zamówień, static cache dla information_schema, indeksy wydajnościowe na tabeli orders**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~8min |
|
||||
| Started | 2026-03-14 |
|
||||
| Completed | 2026-03-14 |
|
||||
| Tasks | 3 completed |
|
||||
| Files modified | 2 (1 modified, 1 created) |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: Brak correlated subqueries w liście zamówień | Pass | 4 subqueries zastąpione aggregating LEFT JOINs; grep potwierdza zero `SELECT COUNT(*) FROM order_items WHERE oi.order_id` |
|
||||
| AC-2: information_schema nie odpytywany per-request | Pass | `private static ?bool $supportsMappedMedia` + `self::$supportsMappedMedia` — max 1× na cykl PHP |
|
||||
| AC-3: Brakujące indeksy dodane migracją | Pass | Migracja 000048: source, external_status_id, ordered_at, composite (source, external_status_id); IF NOT EXISTS |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- 4 correlated subqueries (items_count, items_qty, shipments_count, documents_count) → 3 aggregating LEFT JOINs — eliminacja ~200 dodatkowych zapytań przy 50 wierszach na stronę
|
||||
- `canResolveMappedMedia()` z instance na static property — information_schema odpytywany max 1× na cykl PHP
|
||||
- 4 brakujące indeksy na tabeli orders dla typowych filtrów/sortowań
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `src/Modules/Orders/OrdersRepository.php` | Modified | LEFT JOINs zamiast subqueries w buildListSql(); static cache w canResolveMappedMedia() |
|
||||
| `database/migrations/20260314_000048_add_orders_performance_indexes.sql` | Created | Indeksy: source, external_status_id, ordered_at, composite (source, external_status_id) |
|
||||
| `DOCS/DB_SCHEMA.md` | Modified | Wpis o migracji 000048 |
|
||||
| `DOCS/TECH_CHANGELOG.md` | Modified | Wpis 2026-03-14 o optymalizacjach |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| Pominięto indeks na allegro_order_status_mappings.allegro_status_code | Tabela już ma UNIQUE KEY na tej kolumnie (migracja 000025) | Brak duplikatu indeksu |
|
||||
| Data migracji 20260314 zamiast 20260313 | Wykonanie w dniu 2026-03-14 | Numeracja zgodna z datą faktycznego utworzenia |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Auto-fixed | 0 | - |
|
||||
| Scope additions | 0 | - |
|
||||
| Deferred | 0 | - |
|
||||
|
||||
**Total impact:** Plan wykonany zgodnie ze specyfikacją. Jedyna różnica: pominięcie zbędnego indeksu na allegro_order_status_mappings (UNIQUE KEY już istniał).
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None
|
||||
|
||||
## Verification Results
|
||||
|
||||
```
|
||||
✓ php -l src/Modules/Orders/OrdersRepository.php — No syntax errors
|
||||
✓ grep correlated subqueries — 0 matches (eliminated)
|
||||
✓ grep supportsMappedMedia — static + self:: confirmed
|
||||
✓ Migration 000048 — exists, non-empty, idempotent (IF NOT EXISTS)
|
||||
```
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- OrdersRepository zoptymalizowany — lista zamówień gotowa na wzrost danych
|
||||
- Plan 07-02 (SSL + cron + migration) niezależny, może być wykonany natychmiast
|
||||
|
||||
**Concerns:**
|
||||
- Migracja 000048 wymaga uruchomienia na środowisku docelowym
|
||||
|
||||
**Blockers:**
|
||||
- None
|
||||
|
||||
---
|
||||
*Phase: 07-pre-expansion-fixes, Plan: 01*
|
||||
*Completed: 2026-03-14*
|
||||
132
.paul/phases/07-pre-expansion-fixes/07-02-SUMMARY.md
Normal file
132
.paul/phases/07-pre-expansion-fixes/07-02-SUMMARY.md
Normal file
@@ -0,0 +1,132 @@
|
||||
---
|
||||
phase: 07-pre-expansion-fixes
|
||||
plan: 02
|
||||
subsystem: security, infra
|
||||
tags: [ssl, curl, cron-throttle, migration-dedup, app-settings]
|
||||
|
||||
requires:
|
||||
- phase: 06-sonarqube-quality
|
||||
provides: ApiClient classes refactored
|
||||
provides:
|
||||
- SSL verification in all 4 ApiClient classes
|
||||
- DB-backed cron web throttle (no more $_SESSION dependency)
|
||||
- Deduplicated migration sequence (000014b)
|
||||
affects: [07-03, 07-04, 07-05]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [getCaBundlePath-per-client, app-settings-as-kv-store]
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- database/migrations/20260314_000049_add_cron_last_run_at_setting.sql
|
||||
modified:
|
||||
- src/Modules/Settings/AllegroApiClient.php
|
||||
- src/Modules/Settings/AllegroOAuthClient.php
|
||||
- src/Modules/Settings/ShopproApiClient.php
|
||||
- src/Modules/Settings/ApaczkaApiClient.php
|
||||
- src/Core/Application.php
|
||||
- .env.example
|
||||
- database/migrations/20260301_000014b_add_products_sku_format_setting.sql (renamed)
|
||||
|
||||
key-decisions:
|
||||
- "getCaBundlePath() per class — no shared trait, acceptable duplication for 4 classes"
|
||||
- "ON DUPLICATE KEY UPDATE with named params :ts/:ts2 (PDO limitation — no repeated named params)"
|
||||
|
||||
patterns-established:
|
||||
- "SSL: CURLOPT_SSL_VERIFYPEER=true + CURLOPT_SSL_VERIFYHOST=2 + CURLOPT_CAINFO in every curl call"
|
||||
- "app_settings as key-value store for cross-session state"
|
||||
|
||||
duration: ~10min
|
||||
started: 2026-03-14
|
||||
completed: 2026-03-14
|
||||
---
|
||||
|
||||
# Phase 7 Plan 02: SSL + Cron Throttle + Migration Dedup Summary
|
||||
|
||||
**SSL verification w 4 ApiClient klasach, cron throttle przeniesiony z $_SESSION do app_settings DB, deduplikacja migracji 000014**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~10min |
|
||||
| Started | 2026-03-14 |
|
||||
| Completed | 2026-03-14 |
|
||||
| Tasks | 3 completed |
|
||||
| Files modified | 8 (6 modified, 1 created, 1 renamed) |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: SSL weryfikowany w każdym cURL wywołaniu | Pass | 6 curl_setopt_array blocks w 4 plikach mają CURLOPT_SSL_VERIFYPEER=true + VERIFYHOST=2 + CAINFO |
|
||||
| AC-2: Web cron throttle oparty na DB | Pass | $_SESSION['cron_web_last_run_at'] usunięty; getWebCronLastRunAt()/setWebCronLastRunAt() czytają/piszą app_settings |
|
||||
| AC-3: Migracja 000014 zdeduplikowana | Pass | git mv → 000014b; INSERT ON DUPLICATE KEY UPDATE (idempotentna) |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- 4 klasy ApiClient (6 miejsc cURL) zabezpieczone SSL verification z fallback chain: ENV → XAMPP → system
|
||||
- Cron web throttle nie zależy od sesji — działa poprawnie przy wielu aktywnych sesjach
|
||||
- Sekwencja migracji czysta — brak duplikatów numerów
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `src/Modules/Settings/AllegroApiClient.php` | Modified | SSL opts w postJson(), postBinary(), requestJson() + getCaBundlePath() |
|
||||
| `src/Modules/Settings/AllegroOAuthClient.php` | Modified | SSL opts w requestToken() + getCaBundlePath() |
|
||||
| `src/Modules/Settings/ShopproApiClient.php` | Modified | SSL opts w requestJson() + getCaBundlePath() |
|
||||
| `src/Modules/Settings/ApaczkaApiClient.php` | Modified | SSL opts w executeRequest() + getCaBundlePath() |
|
||||
| `src/Core/Application.php` | Modified | isWebCronThrottled() → app_settings; +getWebCronLastRunAt(), +setWebCronLastRunAt() |
|
||||
| `.env.example` | Modified | Dodano CURL_CA_BUNDLE_PATH |
|
||||
| `database/migrations/20260314_000049_add_cron_last_run_at_setting.sql` | Created | Seed cron_web_last_run_at w app_settings |
|
||||
| `database/migrations/20260301_000014b_...` | Renamed | git mv z 000014 na 000014b |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| getCaBundlePath() w każdej klasie osobno | Brak wspólnego traita/klasy bazowej; 4 kopie to akceptowalna duplikacja vs. przedwczesna abstrakcja | Przyszła refaktoryzacja może wydzielić trait |
|
||||
| PDO named params :ts/:ts2 w ON DUPLICATE KEY | PDO nie pozwala na powtórzenie tego samego named param; użyto dwóch nazw | Standardowy workaround |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Auto-fixed | 1 | Minimal |
|
||||
| Scope additions | 0 | - |
|
||||
| Deferred | 0 | - |
|
||||
|
||||
**Total impact:** Minimalna odchyłka — data pliku migracji zmieniona z 20260313 na 20260314.
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. Data migracji**
|
||||
- **Found during:** Task 2
|
||||
- **Issue:** Plan proponował `20260313_000049`, ale wykonanie było 2026-03-14
|
||||
- **Fix:** Użyto `20260314_000049` zgodnie z datą wykonania
|
||||
- **Verification:** Plik istnieje, spójna konwencja nazewnicza
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- Wszystkie ApiClienty bezpieczne pod SSL — nowe integracje mogą kopiować wzorzec
|
||||
- Cron throttle stabilny dla wielu sesji
|
||||
- Plan 07-03 (UX fixes) niezależny, może być wykonany natychmiast
|
||||
|
||||
**Concerns:**
|
||||
- Migracja 000049 wymaga uruchomienia na środowisku docelowym
|
||||
|
||||
**Blockers:**
|
||||
- None
|
||||
|
||||
---
|
||||
*Phase: 07-pre-expansion-fixes, Plan: 02*
|
||||
*Completed: 2026-03-14*
|
||||
145
.paul/phases/07-pre-expansion-fixes/07-03-SUMMARY.md
Normal file
145
.paul/phases/07-pre-expansion-fixes/07-03-SUMMARY.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
phase: 07-pre-expansion-fixes
|
||||
plan: 03
|
||||
subsystem: ui, security
|
||||
tags: [ux, status-colors, ssl-hotfix, delivery-mapping-bug]
|
||||
|
||||
requires:
|
||||
- phase: 07-pre-expansion-fixes
|
||||
provides: Plan 07-02 SSL verification (hotfixed here)
|
||||
provides:
|
||||
- orderpro_to_allegro sync disabled (ok:false + UI disabled)
|
||||
- Orders list: source before ID, "ID:" prefix, sourceLabel()
|
||||
- Status badges colored by group color_hex from config
|
||||
- Darker form borders (#e2e8f0 → #b0bec5)
|
||||
- SSL getCaBundlePath() hotfix — nullable, CAINFO only when file exists
|
||||
affects: [07-04, 07-05]
|
||||
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns: [statusColorMap, sourceLabel, conditional-curlopt-cainfo]
|
||||
|
||||
key-files:
|
||||
modified:
|
||||
- src/Modules/Settings/AllegroStatusSyncService.php
|
||||
- resources/views/settings/allegro.php
|
||||
- src/Modules/Orders/OrdersController.php
|
||||
- resources/scss/shared/_ui-components.scss
|
||||
- public/assets/css/app.css
|
||||
- src/Modules/Settings/AllegroApiClient.php
|
||||
- src/Modules/Settings/AllegroOAuthClient.php
|
||||
- src/Modules/Settings/ShopproApiClient.php
|
||||
- src/Modules/Settings/ApaczkaApiClient.php
|
||||
|
||||
key-decisions:
|
||||
- "sourceLabel() z match expression — mapuje shoppro→shopPRO, allegro→Allegro, erli→Erli"
|
||||
- "statusColorMap() z group color_hex — status badge inline style gdy kolor dostępny, fallback na CSS klasy"
|
||||
- "SSL CURLOPT_CAINFO warunkowy — null gdy żaden CA bundle nie znaleziony, cURL używa systemowego"
|
||||
|
||||
patterns-established:
|
||||
- "Status coloring: statusColorMap() + inline style background-color + color:#fff"
|
||||
- "SSL: getCaBundlePath() nullable + withSslOptions() helper (AllegroApiClient)"
|
||||
|
||||
duration: ~20min
|
||||
started: 2026-03-14
|
||||
completed: 2026-03-14
|
||||
---
|
||||
|
||||
# Phase 7 Plan 03: UX Fixes Summary
|
||||
|
||||
**Disable orderpro_to_allegro sync, source/ID swap w liście zamówień, kolorowanie statusów, ciemniejsze bordery + hotfix SSL CA bundle**
|
||||
|
||||
## Performance
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Duration | ~20min |
|
||||
| Started | 2026-03-14 |
|
||||
| Completed | 2026-03-14 |
|
||||
| Tasks | 3 completed (+ checkpoint) |
|
||||
| Files modified | 10 |
|
||||
|
||||
## Acceptance Criteria Results
|
||||
|
||||
| Criterion | Status | Notes |
|
||||
|-----------|--------|-------|
|
||||
| AC-1: orderpro_to_allegro nie daje false-positive | Pass | `ok: false` w early return |
|
||||
| AC-2: Opcja UI disabled | Pass | `disabled` + "(wkrótce)" na option |
|
||||
| AC-3: Source przed ID + prefix "ID:" | Pass | sourceLabel() + swap kolejności spanów |
|
||||
| AC-4: Statusy kolorowane | Pass | statusColorMap() → inline style background-color |
|
||||
| AC-5: Ciemniejsze obramowanie | Pass | --c-border: #e2e8f0 → #b0bec5, CSS rebuilt |
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- orderpro_to_allegro sync zwraca ok:false (nie ok:true), opcja UI disabled z "(wkrótce)"
|
||||
- Lista zamówień: source (Allegro/shopPRO/Erli) przed ID z prefixem "ID:"
|
||||
- Statusy kolorowane kolorem grupy z konfiguracji, fallback na CSS klasy dla niezamapowanych
|
||||
- Ciemniejsze obramowanie formularzy w całej aplikacji
|
||||
- **Hotfix SSL:** getCaBundlePath() zwraca null gdy żaden CA bundle nie znaleziony — cURL używa systemowego domyślnego, eliminuje błąd na serwerze
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
| File | Change | Purpose |
|
||||
|------|--------|---------|
|
||||
| `src/Modules/Settings/AllegroStatusSyncService.php` | Modified | ok:true → ok:false dla orderpro_to_allegro |
|
||||
| `resources/views/settings/allegro.php` | Modified | disabled + "(wkrótce)" na opcji sync direction |
|
||||
| `src/Modules/Orders/OrdersController.php` | Modified | sourceLabel(), statusColorMap(), statusBadge() z kolorem, swap source/ID |
|
||||
| `resources/scss/shared/_ui-components.scss` | Modified | --c-border: #b0bec5 |
|
||||
| `public/assets/css/app.css` | Rebuilt | CSS z nowym border color |
|
||||
| `src/Modules/Settings/AllegroApiClient.php` | Modified | getCaBundlePath() nullable + withSslOptions() |
|
||||
| `src/Modules/Settings/AllegroOAuthClient.php` | Modified | getCaBundlePath() nullable, warunkowy CAINFO |
|
||||
| `src/Modules/Settings/ShopproApiClient.php` | Modified | getCaBundlePath() nullable, warunkowy CAINFO |
|
||||
| `src/Modules/Settings/ApaczkaApiClient.php` | Modified | getCaBundlePath() nullable, warunkowy CAINFO |
|
||||
|
||||
## Decisions Made
|
||||
|
||||
| Decision | Rationale | Impact |
|
||||
|----------|-----------|--------|
|
||||
| sourceLabel() match expression | Czytelne mapowanie 3 znanych źródeł + ucfirst fallback | Łatwe do rozszerzenia o nowe źródła |
|
||||
| Status color inline style | group color_hex z konfiguracji; brak kolumny color w wierszu zamówienia | Nie wymaga migracji, kolor pochodzi z istniejącej tabeli order_status_groups |
|
||||
| SSL CAINFO warunkowy | Serwer produkcyjny nie ma lokalnych CA bundle paths, cURL ma wbudowany systemowy | Eliminuje błąd "error setting certificate verify locations" |
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Summary
|
||||
|
||||
| Type | Count | Impact |
|
||||
|------|-------|--------|
|
||||
| Auto-fixed | 1 | Critical — SSL hotfix z planu 07-02 |
|
||||
| Scope additions | 0 | - |
|
||||
| Deferred | 1 | Pre-existing bug |
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. SSL CA bundle path error na serwerze**
|
||||
- **Found during:** Checkpoint verification (user report)
|
||||
- **Issue:** getCaBundlePath() zwracał hardcoded path który nie istnieje na serwerze → cURL error
|
||||
- **Fix:** getCaBundlePath() zwraca null gdy brak pliku; CURLOPT_CAINFO ustawiany warunkowo
|
||||
- **Files:** 4 ApiClient klasy
|
||||
- **Verification:** User potwierdzi po deploy
|
||||
|
||||
### Deferred Items
|
||||
|
||||
- **Pre-existing:** Pole "Szukaj..." w mapowaniu form dostawy Allegro — JS `attachSelectFilter()` tworzy input search dla InPost/Apaczka selectów, layout myląco wygląda jakby należał do wiersza powyżej
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
| Issue | Resolution |
|
||||
|-------|------------|
|
||||
| SSL error na serwerze produkcyjnym | getCaBundlePath() → nullable, CAINFO warunkowy |
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
**Ready:**
|
||||
- UX fixes wdrożone, lista zamówień czytelniejsza
|
||||
- Plan 07-04 (testy) niezależny
|
||||
|
||||
**Concerns:**
|
||||
- Delivery mapping "Szukaj..." layout — pre-existing, do naprawy osobno
|
||||
|
||||
**Blockers:**
|
||||
- None
|
||||
|
||||
---
|
||||
*Phase: 07-pre-expansion-fixes, Plan: 03*
|
||||
*Completed: 2026-03-14*
|
||||
Reference in New Issue
Block a user