"""Quick test of a few representative files."""
import time
from pathlib import Path
from src.extraction_v2.pipeline import ExtractionPipelineV2

# Test files - small and medium sized
test_files = [
    "/home/hieutt50/projects/DSOL/AIHackathonFolder/Phase2/CustomerDocument/чФ╗щЭвшиншиИч╖и/02_чФ╗щЭвф╗ХцзШ/01_щА▓цНЧчобчРЖцйЯшГ╜/хИеч┤Щ_01.02.01.03.05_х╖еф║ЛщА▓цНЧщБЕх╗╢уГБуВзуГГуВп.xlsx",  # Small 0.03MB
    "/home/hieutt50/projects/DSOL/AIHackathonFolder/Phase2/CustomerDocument/уВ╖уВЩуГзуГХуВЩф╕Ашжз/1.1 JP1уВ╣уВ▒уВ╖уВЩуГеуГ╝уГлф╕Ашжз.xlsx",  # Medium 0.33MB
    "/home/hieutt50/projects/DSOL/AIHackathonFolder/Phase2/CustomerDocument/уВ╖уВЩуГзуГХуВЩф╕Ашжз/1.3 уВвуВпуВ╗уВ╣PFя╝ИхЕЙя╝ЙуВ╖уВзуГлф╕Ашжз.xlsm",  # Medium .xlsm 0.21MB, 13 sheets
]

results = []

for file_path in test_files:
    print(f"\n{'='*80}")
    print(f"Testing: {Path(file_path).name}")
    print('='*80)

    start = time.time()
    try:
        pipeline = ExtractionPipelineV2()
        result = pipeline.process_document_sync(None, file_path)
        elapsed = round(time.time() - start, 2)

        if result.success:
            print(f"✓ SUCCESS")
            print(f"  Records: {result.record_count}")
            print(f"  Time: {elapsed}s")

            # Get unique sheet names
            sheet_names = set(r.sheet_name for r in result.records if r.sheet_name)
            print(f"  Sheets: {len(sheet_names)} - {', '.join(list(sheet_names)[:3])}")

            results.append({
                "file": Path(file_path).name,
                "status": "success",
                "records": result.record_count,
                "time": elapsed
            })
        else:
            print(f"✗ FAILED: {result.error}")
            results.append({
                "file": Path(file_path).name,
                "status": "error",
                "error": result.error,
                "time": elapsed
            })
    except Exception as e:
        elapsed = round(time.time() - start, 2)
        print(f"✗ EXCEPTION: {str(e)}")
        results.append({
            "file": Path(file_path).name,
            "status": "exception",
            "error": str(e),
            "time": elapsed
        })

print("\n" + "="*80)
print("SUMMARY")
print("="*80)
for r in results:
    status_icon = "✓" if r["status"] == "success" else "✗"
    print(f"{status_icon} {r['file']}: {r['status']} ({r['time']}s)")
    if r["status"] == "success":
        print(f"   {r['records']} records")
