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.
This commit is contained in:
parent
fc9155de58
commit
64a317f45f
@ -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}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user