feat: Add A-Z filter for clients/suppliers in Telegram bot

- Add A-Z alphabetical filter keyboard for clients and suppliers lists
  (same pattern as company selection, without emoji)
- Increase clients/suppliers list pagination from 10 to 20 items per page
- Remove emoji from company A-Z filter button for consistency
- Add 6 new callback handlers: clients_alpha_menu, clients_alpha:LETTER,
  clients_alpha_page:PAGE:LETTER, and supplier equivalents
- Dashboard service and models updates
- Telegram bot: email handlers, auth, DB operations, internal API improvements
- Frontend: dashboard cards updates (CashFlow, Clienti, Furnizori, Treasury)
- Frontend: SolduriCompactCard and CollapsibleCard improvements
- DashboardView enhancements
- start.sh and run-with-restart.sh script updates
- IIS web.config and service worker updates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-02-21 14:34:15 +00:00
parent 1366dbc11c
commit 30f55cf18b
28 changed files with 1671 additions and 520 deletions

View File

@@ -11,6 +11,18 @@ LOG_FILE=${2:-/tmp/unified_backend.log}
MAX_RESTARTS=10
RESTART_COUNT=0
RESTART_DELAY=3
UVICORN_PID=""
# On SIGTERM or SIGINT: kill uvicorn child and exit cleanly (no restart)
cleanup_and_exit() {
echo "[Backend Runner] Received termination signal, stopping..." | tee -a "$LOG_FILE"
if [ -n "$UVICORN_PID" ] && kill -0 "$UVICORN_PID" 2>/dev/null; then
kill "$UVICORN_PID" 2>/dev/null
wait "$UVICORN_PID" 2>/dev/null
fi
exit 0
}
trap cleanup_and_exit SIGTERM SIGINT
echo "[Backend Runner] Starting uvicorn with auto-restart (max $MAX_RESTARTS restarts)" | tee -a "$LOG_FILE"
echo "[Backend Runner] Port: $PORT, Log: $LOG_FILE" | tee -a "$LOG_FILE"
@@ -20,15 +32,27 @@ while [ $RESTART_COUNT -lt $MAX_RESTARTS ]; do
echo "" | tee -a "$LOG_FILE"
echo "[Backend Runner] $(date '+%Y-%m-%d %H:%M:%S') - Starting uvicorn (attempt $((RESTART_COUNT + 1))/$MAX_RESTARTS)..." | tee -a "$LOG_FILE"
# Run uvicorn - it will exit on crash (OOM, etc.)
uvicorn main:app --host 0.0.0.0 --port "$PORT" 2>&1 | tee -a "$LOG_FILE"
# Run uvicorn in background so we can track its PID and trap signals properly
uvicorn main:app --host 0.0.0.0 --port "$PORT" >> "$LOG_FILE" 2>&1 &
UVICORN_PID=$!
# Wait for uvicorn to exit
wait "$UVICORN_PID"
EXIT_CODE=$?
UVICORN_PID=""
END_TIME=$(date +%s)
RUNTIME=$((END_TIME - START_TIME))
echo "[Backend Runner] $(date '+%Y-%m-%d %H:%M:%S') - uvicorn exited with code $EXIT_CODE after ${RUNTIME}s" | tee -a "$LOG_FILE"
# Exit if trap already fired (cleanup_and_exit sets UVICORN_PID="")
# or if uvicorn exited due to a signal (130=SIGINT, 143=SIGTERM, 137=SIGKILL)
if [ $EXIT_CODE -eq 130 ] || [ $EXIT_CODE -eq 143 ] || [ $EXIT_CODE -eq 137 ]; then
echo "[Backend Runner] Received termination signal (code $EXIT_CODE), exiting..." | tee -a "$LOG_FILE"
exit 0
fi
# If it ran for more than 60 seconds, reset restart counter (was stable)
if [ $RUNTIME -gt 60 ]; then
RESTART_COUNT=0
@@ -38,12 +62,6 @@ while [ $RESTART_COUNT -lt $MAX_RESTARTS ]; do
echo "[Backend Runner] Quick crash detected, restart count: $RESTART_COUNT/$MAX_RESTARTS" | tee -a "$LOG_FILE"
fi
# Exit if user sent SIGINT (Ctrl+C) or SIGTERM
if [ $EXIT_CODE -eq 130 ] || [ $EXIT_CODE -eq 143 ]; then
echo "[Backend Runner] Received termination signal, exiting..." | tee -a "$LOG_FILE"
exit 0
fi
# Wait before restart
if [ $RESTART_COUNT -lt $MAX_RESTARTS ]; then
echo "[Backend Runner] Restarting in ${RESTART_DELAY}s..." | tee -a "$LOG_FILE"