from pathlib import Path

for name in ("staff.py", "booking.py", "attendance.py"):
    p = Path("app/services") / name
    lines = p.read_text(encoding="utf-8").splitlines()
    fixed = []
    for line in lines:
        if line.startswith("                await self.session.commit()"):
            fixed.append("        await self.session.commit()")
        elif line.startswith("                await self.session.refresh("):
            fixed.append("        await self.session.refresh(entity)")
        else:
            fixed.append(line)
    p.write_text("\n".join(fixed) + "\n", encoding="utf-8")
    print("cleaned", p)
