Skip to content

1.9.0

βš™οΈ Patch 1.9.0 β€” Analysis page update

πŸš€ Summary

  • Analysis (/analysis) is the dedicated article analytics surface: Metabase Guest dashboard embed plus a KPI table aligned with Multi Repricer filtering.
  • Article KPIs support preset periods (7 / 14 / 30 / 90 days) and a custom From/To date window (max 365 days).
  • Advanced filters cover buy price, stock, period profit, sales/returns qty, return rate (%), gross revenue, ad costs, and ad cost / sale.
  • UI wording uses Return (not Retour); table column Ad cost applied is replaced by Ad cost / sale for the selected period.
  • Results are cached in localStorage (10 minutes) with an explicit Refresh button.
  • Metabase uses Modular Guest embedding (embed.js + <metabase-dashboard>, isGuest: true) β€” not the paid React SDK. Site URL must be HTTPS.

✨ Details

Article analytics table

Area Behavior
Search / filters SKU, name, Has Details (Shopify / Kaufland / Otto / FBM / FBA), Article Type, advanced rules
Period Last 7 / 14 / 30 / 90 days, or Custom… with From / To
KPI filters Applied after sales-stats merge for the selected window; return rate expects percent (e.g. 15 = 15%)
Columns Stock, sales qty, return qty/rate, period profit, gross revenue, Otto ad costs, ad cost / sale
Cache localStorage key per filter/period/page; Refresh forces reload

Sales stats API

  • GET /articles/stats/sales and GET /articles/{sku}/stats/sales accept optional from_date + to_date (YYYY-MM-DD, inclusive) instead of days.
  • Batch + dialog clients pass the Analysis window through to these endpoints.

Metabase Guest embed

  • Backend GET /api/v1/multi/metabase/embed-token signs a Guest JWT (resource.dashboard, params, exp, _embedding_params).
  • Embed JWT lifetime follows ACCESS_TOKEN_EXPIRE_MINUTES.
  • Frontend loads https://…/app/embed.js, sets metabaseConfig with isGuest: true, mounts <metabase-dashboard token="…"> without inline styles.
  • Compose sets Metabase MB_SITE_URL (HTTPS) and MB_ENABLE_EMBEDDING_SIMPLE=true.
  • Shopify shopify_deferred_export_retry cron: every hour (was every 3 minutes); startup upserts the schedule if still */3.
  • Otto SPA daily ads: richer logging; DB upsert after each report batch; Sync Ads date-range backfill unchanged from 1.8.x.

πŸ”§ Deploy

  1. Ensure Postgres update from 1.8.x is applied if not already:
-- docker/postgres/updates/otto_ad_daily.sql
  1. Set env for service-multi-repricer:
Variable Example
METABASE_SITE_URL https://metabase.lage-beauty.de
METABASE_SECRET_KEY Embedding secret from Metabase Admin β†’ Embedding
METABASE_DASHBOARD_ID 3 (must match the published Guest dashboard)
ACCESS_TOKEN_EXPIRE_MINUTES Controls embed JWT exp
  1. Redeploy Metabase with:
MB_SITE_URL=https://metabase.lage-beauty.de
MB_ENABLE_EMBEDDING_SIMPLE=true
  1. In Metabase Admin:
  2. Site URL = https://metabase.lage-beauty.de (not http://)
  3. Embedding β†’ enable Guest embeds
  4. Publish the target dashboard for Guest embedding

  5. Redeploy service-multi-repricer + frontend.

πŸ“š Docs / code

  • Frontend: frontend/src/pages/Analysis/
  • Embed API: backend/service_multi-repricer/app/api/v1/endpoints/metabase.py
  • Sales stats: backend/service_multi-repricer/app/api/v1/endpoints/article_stats.py
  • Compose: MB_SITE_URL / MB_ENABLE_EMBEDDING_SIMPLE on the metabase service