Replace import_orders (insert-per-run) with orders table (one row per order, upsert on conflict). Eliminates dedup CTE on every dashboard query and prevents unbounded row growth at 4-500 orders/sync. Key changes: - orders table: PK order_number, upsert via ON CONFLICT DO UPDATE; COALESCE preserves id_comanda once set; times_skipped auto-increments - sync_run_orders: lightweight junction (sync_run_id, order_number) replaces sync_run_id column on orders - order_items: PK changed to (order_number, sku), INSERT OR IGNORE - Auto-migration in init_sqlite(): import_orders → orders on first boot, old table renamed to import_orders_bak - /api/dashboard/orders: period_days param (3/7/30/0=all, default 7) - Dashboard: period selector buttons in orders card header - start.sh: stop existing process on port 5003 before restart; remove --reload (broken on WSL2 /mnt/e/) - Add invoice_service, E2E Playwright tests, Oracle package updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
971 B
Bash
36 lines
971 B
Bash
#!/bin/bash
|
|
# Start GoMag Import Manager - WSL/Linux
|
|
cd "$(dirname "$0")"
|
|
|
|
# Create venv if it doesn't exist
|
|
if [ ! -d "venv" ]; then
|
|
echo "Creating virtual environment..."
|
|
python3 -m venv venv
|
|
fi
|
|
|
|
# Activate venv
|
|
source venv/bin/activate
|
|
|
|
# Install/update dependencies if needed
|
|
if [ api/requirements.txt -nt venv/.deps_installed ] || [ ! -f venv/.deps_installed ]; then
|
|
echo "Installing dependencies..."
|
|
pip install -r api/requirements.txt
|
|
touch venv/.deps_installed
|
|
fi
|
|
|
|
# Stop any existing instance on port 5003
|
|
EXISTING_PID=$(lsof -ti tcp:5003 2>/dev/null)
|
|
if [ -n "$EXISTING_PID" ]; then
|
|
echo "Stopping existing process on port 5003 (PID $EXISTING_PID)..."
|
|
kill "$EXISTING_PID"
|
|
sleep 2
|
|
fi
|
|
|
|
# Oracle config
|
|
export TNS_ADMIN="$(pwd)/api"
|
|
export LD_LIBRARY_PATH=/opt/oracle/instantclient_21_15:$LD_LIBRARY_PATH
|
|
|
|
cd api
|
|
echo "Starting GoMag Import Manager on http://0.0.0.0:5003"
|
|
python -m uvicorn app.main:app --host 0.0.0.0 --port 5003
|