#!/usr/bin/env bash
# Pipeline refresh: extract missing ideas, re-score, then re-run gap analysis
# Run from project root: bash scripts/pipeline-refresh.sh

set -euo pipefail
cd "$(dirname "$0")/.."
export PYTHONPATH=src

echo "=== Step 1/3: Extract ideas from 38 remaining drafts ==="
python -m ietf_analyzer.cli ideas --all --cheap --batch 5 --limit 50

echo ""
echo "=== Step 2/3: Score new ideas for novelty ==="
python -m ietf_analyzer.cli ideas score --cheap --batch 10

echo ""
echo "=== Step 3/3: Re-run gap analysis ==="
python -m ietf_analyzer.cli gaps --refresh

echo ""
echo "=== Done ==="
python -c "
from ietf_analyzer.config import Config
from ietf_analyzer.db import Database
cfg = Config.load()
db = Database(cfg)
ideas = db.conn.execute('SELECT count(*) FROM ideas').fetchone()[0]
gaps = db.conn.execute('SELECT count(*) FROM gaps').fetchone()[0]
print(f'Ideas: {ideas}, Gaps: {gaps}')
"
