Skip to content

Commit dfad1d1

Browse files
ISSUE #1106 #1096: Improve combined activity charts
1 parent 40b3753 commit dfad1d1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Domain/Activity/Stream/CombinedStream/CalculateCombinedStreams/CalculateCombinedStreamsCommandHandler.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ public function handle(Command $command): void
9898
$distanceInKm = Meter::from($row[$distanceIndex])->toKilometer();
9999
$row[$distanceIndex] = $distanceInKm->toFloat();
100100

101+
if (UnitSystem::IMPERIAL === $this->unitSystem) {
102+
$row[$distanceIndex] = $distanceInKm->toMiles()->toFloat();
103+
}
104+
105+
if (false !== $altitudeIndex && UnitSystem::IMPERIAL === $this->unitSystem) {
106+
$row[$altitudeIndex] = Meter::from($row[$altitudeIndex])->toFoot()->toFloat();
107+
}
108+
101109
if (false !== $paceIndex) {
102110
$secondsPerKilometer = MetersPerSecond::from($row[$paceIndex])->toSecPerKm();
103111
if (UnitSystem::IMPERIAL === $this->unitSystem) {
@@ -118,13 +126,6 @@ public function handle(Command $command): void
118126
}
119127
}
120128

121-
if (UnitSystem::IMPERIAL === $this->unitSystem) {
122-
$row[$distanceIndex] = $distanceInKm->toMiles()->toFloat();
123-
if (false !== $altitudeIndex) {
124-
$row[$altitudeIndex] = Meter::from($row[$altitudeIndex])->toFoot()->toFloat();
125-
}
126-
}
127-
128129
// Apply rounding rules.
129130
$row[$distanceIndex] = match ($activityType) {
130131
ActivityType::RIDE => $row[$distanceIndex] < 1 ? round($row[$distanceIndex], 1) : round($row[$distanceIndex]),

0 commit comments

Comments
 (0)