api: PUT /assignments/:id/transport gains direction (outgoing|incoming)

This commit is contained in:
Ida Rogalska
2026-08-11 19:06:02 +02:00
committed by Maurice
parent edb21b681f
commit cedbe39b35
4 changed files with 87 additions and 1 deletions
@@ -175,7 +175,9 @@ export class AssignmentOpsController {
if (!this.assignments.getAssignmentForTrip(id, tripId)) {
throw new HttpException({ error: 'Assignment not found' }, 404);
}
const assignment = this.assignments.setLegTransportMode(id, body.transport_mode ?? null);
const assignment = body.direction === 'incoming'
? this.assignments.setIncomingLegTransportMode(id, body.transport_mode ?? null)
: this.assignments.setLegTransportMode(id, body.transport_mode ?? null);
this.assignments.broadcast(tripId, 'assignment:updated', { assignment }, socketId);
return { assignment };
}
@@ -272,6 +272,17 @@ export class AssignmentsService {
return this.getAssignmentWithPlace(Number(id));
}
/**
* Set the travel mode of the leg arriving at this stop (#1281 boundary legs).
* Mirrors setLegTransportMode but targets incoming_leg_transport_mode; inert
* when the previous timeline element is a place (the column is only read for
* non-place origins like a booking arrival or a morning hotel departure).
*/
setIncomingLegTransportMode(id: string | number, mode: string | null) {
this.dbs.run('UPDATE day_assignments SET incoming_leg_transport_mode = ? WHERE id = ?', mode ?? null, id);
return this.getAssignmentWithPlace(Number(id));
}
setParticipants(assignmentId: string | number, userIds: number[]) {
this.dbs.transaction(() => {
this.dbs.run('DELETE FROM assignment_participants WHERE assignment_id = ?', assignmentId);