Skip to content

Commit

Permalink
front: display duration time only for requested pathsteps
Browse files Browse the repository at this point in the history
Signed-off-by: SarahBellaha <[email protected]>
  • Loading branch information
SarahBellaha committed Jan 7, 2025
1 parent 382d08d commit 00e4d5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const StcdmResults = ({
return getOperationalPointsWithTimes(
outputs.pathProperties?.suggestedOperationalPoints || [],
outputs.results.simulation,
outputs.results.simulationPathSteps,
outputs.results.departure_time
);
}, [outputs]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SimulationResponse } from 'common/api/osrdEditoastApi';
import { interpolateValue } from 'modules/simulationResult/SimulationResultExport/utils';
import type { SuggestedOP } from 'modules/trainschedule/components/ManageTrainSchedule/types';
import type { StdcmPathStep } from 'reducers/osrdconf/types';

import type { StdcmResultsOperationalPoint } from '../types';

Expand Down Expand Up @@ -106,6 +107,7 @@ export function getStopDurationBetweenTwoPositions(
export function getOperationalPointsWithTimes(
operationalPoints: SuggestedOP[],
simulation: Extract<SimulationResponse, { status: 'success' }>,
simulationPathSteps: StdcmPathStep[],
departureTime: string
): StdcmResultsOperationalPoint[] {
const { positions, times } = simulation.final_output;
Expand All @@ -124,8 +126,12 @@ export function getOperationalPointsWithTimes(
departureMinute
);

const isRequestedOp = simulationPathSteps.some(
(step) => step.location?.name === op.name && step.location?.secondary_code === op.ch
);

const duration = getStopDurationBetweenTwoPositions(op.positionOnPath, positions, times);
const durationInSeconds = duration !== null ? duration / 1000 : 0;
const durationInSeconds = isRequestedOp && duration !== null ? duration / 1000 : 0;
const durationToString = secondsToTimeString(durationInSeconds);
const stopEndTime = computeStopDepartureTime(formattedTime, durationToString);

Expand Down

0 comments on commit 00e4d5f

Please sign in to comment.