"""One-shot uploader for the 2 new בל"מ decisions Chaim staged in
data/precedents/incoming/. Bypasses MCP because the running MCP server
was started before SCHEMA_V15 + proceeding_type wiring landed.

Run from /home/chaim/legal-ai with the venv:
    POSTGRES_URL=... .venv/bin/python scripts/upload_blam_decisions.py
"""

import asyncio
import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "mcp-server", "src"))

from legal_mcp.services import internal_decisions as svc

DECISIONS = [
    {
        "file_path": "/home/chaim/legal-ai/data/precedents/incoming/ARAR-24-8126.pdf",
        "case_number": "8126/24",
        "chair_name": "דפנה תמיר",
        "district": "ירושלים",
        "case_name": "הוועדה המקומית ירושלים נ' סופר נוח",
        "court": "ועדת הערר לתכנון ובנייה — מחוז ירושלים",
        "decision_date": "2024-07-07",
        "practice_area": "betterment_levy",
        "appeal_subtype": "extension_request_betterment_levy",
        "proceeding_type": 'בל"מ',
        "subject_tags": ["בקשה_להארכת_מועד", "היטל_השבחה"],
        "summary": "",
        "is_binding": False,
    },
    {
        "file_path": "/home/chaim/legal-ai/data/precedents/incoming/ARAR-23-8047-3.docx",
        "case_number": "8047/23",
        "chair_name": "דפנה תמיר",
        "district": "ירושלים",
        "case_name": 'עזבון אליהו הרנון ז"ל נ\' הוועדה המקומית ירושלים',
        "court": "ועדת הערר לתכנון ובנייה — מחוז ירושלים",
        "decision_date": "2025-09-29",
        "practice_area": "betterment_levy",
        "appeal_subtype": "extension_request_betterment_levy",
        "proceeding_type": 'בל"מ',
        "subject_tags": ["בקשה_להארכת_מועד", "היטל_השבחה"],
        "summary": "",
        "is_binding": False,
    },
]


async def main():
    for d in DECISIONS:
        print(f"→ uploading {d['case_number']} ({d['proceeding_type']})")
        result = await svc.ingest_internal_decision(**d)
        print(f"  ✓ case_law_id={result.get('case_law_id')} chunks={result.get('chunks')}")
    print("done.")


if __name__ == "__main__":
    asyncio.run(main())
