Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions backend/python/app/models/driver_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DriverAssignmentBase(SQLModel):
route_id: UUID = Field(foreign_key="routes.route_id")
route_group_id: UUID = Field(foreign_key="route_groups.route_group_id")
time: datetime = Field()
completed: bool = Field(default=False)


class DriverAssignment(DriverAssignmentBase, BaseModel, table=True):
Expand All @@ -40,4 +39,3 @@ class DriverAssignmentUpdate(SQLModel):
"""Update request model - all optional"""

time: datetime | None = Field(default=None)
completed: bool | None = Field(default=None)
1 change: 0 additions & 1 deletion backend/python/app/seed_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ def main() -> None:
route_id=route_id,
route_group_id=route_group_id,
time=drive_date,
completed=drive_date_obj < today,
)
set_timestamps(assignment)
session.add(assignment)
Expand Down
10 changes: 1 addition & 9 deletions backend/python/app/services/jobs/driver_history_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ async def process_daily_driver_history() -> None:
This job:
1. Finds all incomplete driver assignments from today
2. Calculates total distance for each driver by joining with routes
3. Marks assignments as completed
4. Updates or creates driver history entries with the total distance
3. Updates or creates driver history entries with the total distance
"""
logger = get_logger()

Expand All @@ -51,7 +50,6 @@ async def process_daily_driver_history() -> None:
.join(Route, DriverAssignment.route_id == Route.route_id) # type: ignore[arg-type]
.where(
and_(
DriverAssignment.completed.is_(False), # type: ignore[attr-defined]
DriverAssignment.time >= start_of_day, # type: ignore[arg-type]
DriverAssignment.time <= end_of_day, # type: ignore[arg-type]
)
Expand Down Expand Up @@ -79,12 +77,6 @@ async def process_daily_driver_history() -> None:
)
assignment_ids_to_complete.append(assignment_id)

# Mark all assignments as completed
for assignment_id in assignment_ids_to_complete:
assignment = await session.get(DriverAssignment, assignment_id)
if assignment:
assignment.completed = True

# Update or create driver history entries
for driver_id, total_distance in driver_distances.items():
# Check if history entry exists for this driver and year
Expand Down
1 change: 0 additions & 1 deletion backend/python/app/services/jobs/email_reminder_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ async def process_daily_reminder_emails() -> None:
Driver.user.email is not None, # type: ignore[arg-type]
DriverAssignment.time >= start_of_day, # type: ignore[arg-type]
DriverAssignment.time <= end_of_day, # type: ignore[arg-type]
DriverAssignment.completed.is_(False), # type: ignore[attr-defined]
)
)
.order_by(Driver.user.email)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""remove completed field on driver_assignment

Revision ID: 8b03ae4022cd
Revises: ba76119b3e4c
Create Date: 2026-02-11 01:22:55.339927

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '8b03ae4022cd'
down_revision = 'ba76119b3e4c'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('driver_assignments', 'completed')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('driver_assignments', sa.Column('completed', sa.BOOLEAN(), autoincrement=False, nullable=False))
# ### end Alembic commands ###
4 changes: 2 additions & 2 deletions backend/python/tests/test_driver_assignment_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ async def test_full_crud_workflow(
)

# Update
update_data = DriverAssignmentUpdate(completed=True)
update_data = DriverAssignmentUpdate(time=None)
updated_assignment = await driver_assignment_service.update_driver_assignment(
test_session, created_assignment.driver_assignment_id, update_data
)
assert updated_assignment is not None
assert updated_assignment.completed is True
assert updated_assignment.time is None

# Delete
delete_result = await driver_assignment_service.delete_driver_assignment(
Expand Down
5 changes: 1 addition & 4 deletions backend/python/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@ def test_driver_assignment_core_operations(self) -> None:
route_id=uuid4(),
route_group_id=uuid4(),
time=datetime(2024, 1, 15, 8, 0),
completed=False,
)
assert assignment.completed is False
assert assignment.created_at is not None

# Create with defaults
Expand All @@ -464,10 +462,9 @@ def test_driver_assignment_core_operations(self) -> None:

# Update
assignment_update = DriverAssignmentUpdate(
completed=True,
time=datetime(2024, 1, 15, 9, 0),
)
assert assignment_update.completed is True
assert assignment_update.time == datetime(2024, 1, 15, 9, 0)

def test_driver_history_core_operations(self) -> None:
"""Test DriverHistory model core operations."""
Expand Down
Loading