diff --git a/scripts/auto-ingest-protocols.sh b/scripts/auto-ingest-protocols.sh index b3a9287..b2e89c9 100755 --- a/scripts/auto-ingest-protocols.sh +++ b/scripts/auto-ingest-protocols.sh @@ -32,12 +32,17 @@ for entry in "${PROTO_TARGETS[@]}"; do IFS='|' read -r bl wp pattern <<< "$entry" echo "--- ${bl} WP${wp} ---" - # Hoechste bisher ingesete Sitzungs-Nr fuer diesen BL/WP-Praefix - prefix="MMP${wp}-" # NRW-Konvention; andere BL liefern ihren eigenen Prefix - last_n=$(docker exec "$CONTAINER" sqlite3 /app/data/gwoe-antraege.db \ - "SELECT COALESCE(MAX(CAST(SUBSTR(quelle_protokoll, ${#prefix} + 1) AS INTEGER)), 0) \ - FROM plenum_vote_results \ - WHERE bundesland='${bl}' AND quelle_protokoll LIKE '${prefix}%'" 2>/dev/null || echo "0") + # Hoechste bisher ingestete Sitzungs-Nr fuer diesen BL/WP-Praefix + # python statt sqlite3 — Container hat kein CLI-sqlite3, aber das Python-Modul + prefix="MMP${wp}-" + last_n=$(docker exec "$CONTAINER" python -c " +import sqlite3 +c = sqlite3.connect('/app/data/gwoe-antraege.db').cursor() +c.execute(\"SELECT COALESCE(MAX(CAST(SUBSTR(quelle_protokoll, ${#prefix}+1) AS INTEGER)), 0) FROM plenum_vote_results WHERE bundesland=? AND quelle_protokoll LIKE ?\", ('${bl}', '${prefix}%')) +print(c.fetchone()[0]) +" 2>/dev/null || echo "0") + # Sanity: numeric check + if ! [[ "$last_n" =~ ^[0-9]+$ ]]; then last_n=0; fi start_n=$((last_n + 1)) echo "Letztes ingestes ${prefix}: ${last_n}, probiere ab ${start_n}"