"""One-off: list walk-in customers in DB."""
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))

from sqlalchemy import text
from app.core.database import SessionLocal
from app.constants.walkin_customer import WALKIN_CUSTOMER_ID

db = SessionLocal()
rows = db.execute(
    text(
        """
        SELECT id, name, customer_type, active, branch_id
        FROM customers
        WHERE LOWER(TRIM(name)) LIKE '%walk%'
           OR customer_type = 'walk_in'
        ORDER BY active DESC, name, id
        """
    )
).fetchall()
print(f"Canonical ID: {WALKIN_CUSTOMER_ID}")
for r in rows:
    print(r)
db.close()
