feat(cli): improve member design and usability

This commit is contained in:
2025-08-28 16:21:39 -04:00
parent 954abb704e
commit 94900b19f7
7 changed files with 453 additions and 106 deletions

View File

@@ -234,4 +234,20 @@ class MemberRepository(BaseRepository[MemberModel]):
DeclineStreak = COALESCE(DeclineStreak, 0) + 1
WHERE {self._PK} = ?
"""
self.db.execute(sql, (decline_date, member_id))
self.db.execute(sql, (decline_date, member_id))
def reset_to_queue_front(self, member_id: int) -> None:
"""
Reset member timestamps to move them to the front of the round robin queue.
This sets LastScheduledAt and LastAcceptedAt to far past values, effectively
making them the highest priority for scheduling.
"""
sql = f"""
UPDATE {self._TABLE}
SET LastScheduledAt = '1970-01-01 00:00:00',
LastAcceptedAt = '1970-01-01 00:00:00',
LastDeclinedAt = NULL,
DeclineStreak = 0
WHERE {self._PK} = ?
"""
self.db.execute(sql, (member_id,))

View File

@@ -257,8 +257,14 @@ class ScheduleRepository(BaseRepository[ScheduleModel]):
"""
rows = self.db.fetchall(sql, (service_id, ScheduleStatus.PENDING.value))
return [ScheduleModel.from_row(r) for r in rows]
def delete(self, schedule_id: int) -> None:
"""Harddelete a schedule row (use with caution)."""
def delete_schedule(self, schedule_id: int) -> bool:
"""
Delete a schedule by ID.
Returns:
bool: True if a schedule was deleted, False if not found
"""
sql = f"DELETE FROM {self._TABLE} WHERE {self._PK} = ?"
self.db.execute(sql, (schedule_id,))
cursor = self.db.execute(sql, (schedule_id,))
return cursor.rowcount > 0