Skip to content

1.5.3

⚙️ Patch 1.5.3 — Background tasks and centralized "base" notifications

🚀 New Features

  • Backend: Long-running base repricer operations (full sync, recalculation, export) now run in background tasks so the API remains responsive.
  • WebSocket: Added centralized task_status messages with source: "base" for sync, recalculate and export flows so the frontend sees a single canonical indicator for base activity.

🔧 Improvements

  • shopify_articles.py
  • Converted /recalculate/{sku} and /export-updates to run as background tasks.
  • notify_clients calls for start/finish now run from the background worker and emit canonical task_status payloads.
  • repricer_articles.py
  • sync/{sku} now schedules the heavy sync work in a background task which uses SessionLocal() internally to avoid leaking request DB sessions.
  • Background sync task emits task_status messages with source: "base" for sync start/finish.
  • Background recalculation routine (triggered after sync / UVP updates) now emits base-scoped recalculate and export task_status messages (start/finish) around the work.
  • UVP propagation background task consolidated to run recalculation + platform exports and notify clients with source: "base".
  • Use of local SessionLocal() inside background workers to ensure DB sessions are short-lived and safe across awaits.

🐛 Bug Fixes

  • Fixed blocking endpoints by moving heavy work to background tasks so the server remains responsive under large sync/export runs.
  • Removed duplicated synchronous export path in shopify_articles.py and replaced it with the single background implementation.
  • Ensured notify_clients payloads are canonical task_status dicts (source/task/active/started_at/finished_at/success) so the frontend mapping works reliably.

Files changed

  • backend/service_multi-repricer/app/api/v1/endpoints/shopify_articles.py
  • backend/service_multi-repricer/app/api/v1/endpoints/repricer_articles.py

Notes for operators

  • No DB schema migrations required — only runtime behavior changed.
  • To verify:
  • Trigger a base sync: call the sync/{sku} route and watch the WebSocket /api/v1/multi/ws for task_status messages where source is base and task is sync.
  • Trigger a recalc/export: POST to /recalculate/{sku} or /export-updates and confirm base recalculate/export messages appear (start and finish) in the WS stream.
  • Optionally use the debug endpoint /system/tasks/send to emit a test message for connected clients.
  • If you run multiple backend instances and need shared task state across processes, persist running_map to Redis (recommended) or a shared JSON store. Current persistence is process-local.

SQL

  • N/A