Remove referencias ao Componente B dos scripts de inicializacao
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Escolhe binário do Python (funciona no host ou dentro do container)
|
||||
if [ -x "./venv/bin/python" ]; then
|
||||
VENV_PY="./venv/bin/python"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
@@ -10,7 +9,6 @@ else
|
||||
VENV_PY="python"
|
||||
fi
|
||||
|
||||
# Configs
|
||||
DSN_CANDIDATES=()
|
||||
if [ -n "${ORACLE_LOCAL_DSN:-}" ]; then
|
||||
DSN_CANDIDATES+=("${ORACLE_LOCAL_DSN}")
|
||||
@@ -18,7 +16,7 @@ fi
|
||||
DSN_CANDIDATES+=("127.0.0.1:1521/XEPDB1" "oracle18c:1521/XEPDB1" "mqapilc_oracle18c:1521/XEPDB1")
|
||||
API_URL=${API_URL:-"http://localhost:8000"}
|
||||
|
||||
echo "[1/5] Aguardando Oracle..."
|
||||
echo "[1/4] Aguardando Oracle..."
|
||||
DSN_HOST=""
|
||||
for candidate in "${DSN_CANDIDATES[@]}"; do
|
||||
echo " Testando ${candidate}..."
|
||||
@@ -36,13 +34,13 @@ PY
|
||||
done
|
||||
|
||||
if [ -z "$DSN_HOST" ]; then
|
||||
echo "ERRO: não foi possível conectar ao Oracle em nenhum dos DSN candidatos."
|
||||
echo "ERRO: nao foi possivel conectar ao Oracle em nenhum dos DSN candidatos."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Oracle OK em ${DSN_HOST}."
|
||||
|
||||
echo "[2/5] Conferindo contagem atual..."
|
||||
echo "[2/4] Conferindo contagem atual..."
|
||||
COUNT=$($VENV_PY - <<PY
|
||||
import cx_Oracle
|
||||
conn=cx_Oracle.connect("local123","local123","${DSN_HOST}")
|
||||
@@ -52,19 +50,10 @@ cur.close();conn.close()
|
||||
PY
|
||||
)
|
||||
echo " Registros na TB_RANKING_CONSULTOR: ${COUNT}"
|
||||
MAX_B=$($VENV_PY - <<PY
|
||||
import cx_Oracle
|
||||
conn=cx_Oracle.connect("local123","local123","${DSN_HOST}")
|
||||
cur=conn.cursor();cur.execute("select nvl(max(componente_b),0) from tb_ranking_consultor")
|
||||
print(cur.fetchone()[0])
|
||||
cur.close();conn.close()
|
||||
PY
|
||||
)
|
||||
|
||||
if [ "${COUNT}" -eq 0 ]; then
|
||||
echo "[3/5] Rodando job de ranking (A/C/D)..."
|
||||
echo "[3/4] Rodando job de ranking (Blocos A/C/D)..."
|
||||
curl -s -X POST "${API_URL}/api/v1/ranking/processar?limpar=false" >/dev/null
|
||||
# Espera concluir
|
||||
while true; do
|
||||
STATUS=$(curl -s "${API_URL}/api/v1/ranking/status")
|
||||
running=$($VENV_PY - <<'PY'
|
||||
@@ -79,30 +68,19 @@ STATUS="$STATUS")
|
||||
fi
|
||||
sleep 20
|
||||
done
|
||||
NEED_B="yes"
|
||||
elif [ "${MAX_B}" -eq 0 ]; then
|
||||
echo "[3/5] Tabela já tem dados, mas componente B nunca foi preenchido (max=0)."
|
||||
NEED_B="yes"
|
||||
else
|
||||
echo "[3/5] Tabela já possui dados e componente B preenchido (max=${MAX_B}). Pulando cálculo pesado."
|
||||
NEED_B="no"
|
||||
echo "[3/4] Tabela ja possui dados. Pulando processamento."
|
||||
fi
|
||||
|
||||
if [ "${NEED_B}" = "yes" ]; then
|
||||
echo "[4/5] Rodando Componente B (PPG)..."
|
||||
ORACLE_LOCAL_DSN=${DSN_HOST} PYTHONUNBUFFERED=1 $VENV_PY scripts/popular_componente_b.py
|
||||
else
|
||||
echo "[4/5] Componente B já presente, sem necessidade de recálculo."
|
||||
fi
|
||||
|
||||
echo "[5/5] Contagens finais:"
|
||||
echo "[4/4] Contagens finais:"
|
||||
$VENV_PY - <<PY
|
||||
import cx_Oracle
|
||||
conn=cx_Oracle.connect("local123","local123","${DSN_HOST}")
|
||||
cur=conn.cursor()
|
||||
cur.execute("select count(*) from tb_ranking_consultor"); print("total",cur.fetchone()[0])
|
||||
cur.execute("select count(*) from tb_ranking_consultor where componente_b>0"); print("B>0",cur.fetchone()[0])
|
||||
cur.execute("select max(componente_b) from tb_ranking_consultor"); print("max B",cur.fetchone()[0])
|
||||
cur.execute("select count(*) from tb_ranking_consultor where componente_a>0"); print("Bloco A>0",cur.fetchone()[0])
|
||||
cur.execute("select count(*) from tb_ranking_consultor where componente_c>0"); print("Bloco C>0",cur.fetchone()[0])
|
||||
cur.execute("select count(*) from tb_ranking_consultor where componente_d>0"); print("Bloco D>0",cur.fetchone()[0])
|
||||
cur.execute("select max(pontuacao_total) from tb_ranking_consultor"); print("max total",cur.fetchone()[0])
|
||||
cur.close();conn.close()
|
||||
PY
|
||||
|
||||
Reference in New Issue
Block a user