From 64a317f45fdb87f6ae607484deab384f83880d6f Mon Sep 17 00:00:00 2001 From: Dotty Dotter Date: Tue, 28 Apr 2026 22:29:36 +0200 Subject: [PATCH] fix(#106): auto-ingest-protocols nutzt python statt sqlite3-CLI Container hat kein sqlite3-CLI. docker exec sqlite3 schlug 'OCI runtime exec failed' und last_n wurde zur Fehlermeldung statt einer Zahl, woraufhin set -u im naechsten Arithmetic-Schritt knallte. Fix: python -c mit sqlite3-Modul (Standard-Bibliothek, immer da). Plus Numeric-Sanity-Check als Belt-and-Suspenders. --- scripts/auto-ingest-protocols.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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}"