Add a plan sync endpoint that recomputes, persists and reports the delta
The calendar is becoming the plan: a user edits a period and the schedule updates immediately, with no separate propose and apply steps. POST /api/plan/sync does both and returns a per-date diff against a snapshot taken before any write, so the interface can say what actually moved rather than guessing from coarse counters. Pinned days now mean something. A day the user hand-edited keeps its type and its parent: the loader hides unpinned wish-attributed rows from the allocator so a re-plan is free to move them, while pinned rows stay visible and the existing occupancy check refuses to touch them. Their cost is debited off the pool before any window is funded, following the precedent already set for preschool planning days. Propose and apply are untouched. The allocator stays pure.
This commit is contained in:
@@ -32,6 +32,7 @@ from app.repositories_impl.sqlite.workspace_repository import (
|
||||
SQLiteWorkspaceInvitationRepository,
|
||||
SQLiteWorkspaceRepository,
|
||||
)
|
||||
from app.services.allocation_service import AllocationInputLoader, PlanningEngineService
|
||||
from app.services.analytics_service import AnalyticsService
|
||||
from app.services.auth_service import AuthService
|
||||
from app.services.child_service import ChildService
|
||||
@@ -262,10 +263,43 @@ async def analytics_service(
|
||||
)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def allocation_input_loader(
|
||||
workspace_repo: SQLiteWorkspaceRepository,
|
||||
child_repo: SQLiteChildRepository,
|
||||
personal_data_repo: SQLitePersonalDataRepository,
|
||||
parental_leave_repo: SQLiteParentalLeaveRepository,
|
||||
vacation_repo: SQLiteVacationDaysRepository,
|
||||
planned_leave_repo: SQLitePlannedLeaveRepository,
|
||||
leave_wish_repo: SQLiteLeaveWishRepository,
|
||||
day_override_repo: SQLiteDayOverrideRepository,
|
||||
) -> AllocationInputLoader:
|
||||
return AllocationInputLoader(
|
||||
workspace_repo=workspace_repo,
|
||||
child_repo=child_repo,
|
||||
personal_data_repo=personal_data_repo,
|
||||
parental_leave_repo=parental_leave_repo,
|
||||
vacation_repo=vacation_repo,
|
||||
planned_leave_repo=planned_leave_repo,
|
||||
leave_wish_repo=leave_wish_repo,
|
||||
day_override_repo=day_override_repo,
|
||||
)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def planning_engine_service(
|
||||
allocation_input_loader: AllocationInputLoader,
|
||||
) -> PlanningEngineService:
|
||||
return PlanningEngineService(allocation_input_loader)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def planning_service(
|
||||
planned_leave_repo: SQLitePlannedLeaveRepository,
|
||||
analytics_service: AnalyticsService,
|
||||
parental_leave_repo: SQLiteParentalLeaveRepository,
|
||||
planning_engine_service: PlanningEngineService,
|
||||
) -> PlanningService:
|
||||
return PlanningService(planned_leave_repo, analytics_service, parental_leave_repo)
|
||||
return PlanningService(
|
||||
planned_leave_repo, analytics_service, parental_leave_repo, planning_engine_service
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user