feat(cli): add new schedule member by name feature

This commit is contained in:
2025-09-11 17:02:54 -04:00
parent 0768e4816d
commit 0e536c5b5f
46 changed files with 232 additions and 21093 deletions

View File

@@ -213,12 +213,12 @@ class ScheduleRepository(BaseRepository[ScheduleModel]):
# ------------------------------------------------------------------
def has_schedule_on_date(self, member_id: int, service_date: str) -> bool:
"""
Return ``True`` if *any* schedule (regardless of status) exists for
Return ``True`` if any *active* schedule (pending or accepted) exists for
``member_id`` on the calendar day ``service_date`` (format YYYYMMDD).
This abstracts the a member can only be scheduled once per day
This abstracts the "a member can only be actively scheduled once per day"
rule so the service layer does not need to know the underlying
table layout.
table layout. Declined schedules do not count as blocking.
"""
sql = f"""
SELECT 1
@@ -226,9 +226,10 @@ class ScheduleRepository(BaseRepository[ScheduleModel]):
JOIN Services AS sv ON s.ServiceId = sv.ServiceId
WHERE s.MemberId = ?
AND sv.ServiceDate = ?
AND s.Status IN (?, ?)
LIMIT 1
"""
row = self.db.fetchone(sql, (member_id, service_date))
row = self.db.fetchone(sql, (member_id, service_date, ScheduleStatus.PENDING.value, ScheduleStatus.ACCEPTED.value))
return row is not None
# ------------------------------------------------------------------