@@ -47,6 +47,10 @@ private function __construct(
4747 private Meter $ elevationDifference ,
4848 #[ORM \Column(type: 'integer ' , nullable: true )]
4949 private ?int $ averageHeartRate ,
50+ #[ORM \Column(type: 'integer ' )]
51+ private int $ minMovingTimeInSeconds ,
52+ #[ORM \Column(type: 'integer ' )]
53+ private int $ maxMovingTimeInSeconds ,
5054 ) {
5155 }
5256
@@ -64,6 +68,8 @@ public static function create(
6468 MetersPerSecond $ maxSpeed ,
6569 Meter $ elevationDifference ,
6670 ?int $ averageHeartRate ,
71+ int $ minMovingTimeInSeconds ,
72+ int $ maxMovingTimeInSeconds ,
6773 ): self {
6874 return new self (
6975 lapId: $ lapId ,
@@ -79,6 +85,8 @@ public static function create(
7985 maxSpeed: $ maxSpeed ,
8086 elevationDifference: $ elevationDifference ,
8187 averageHeartRate: $ averageHeartRate ,
88+ minMovingTimeInSeconds: $ minMovingTimeInSeconds ,
89+ maxMovingTimeInSeconds: $ maxMovingTimeInSeconds ,
8290 );
8391 }
8492
@@ -96,6 +104,8 @@ public static function fromState(
96104 MetersPerSecond $ maxSpeed ,
97105 Meter $ elevationDifference ,
98106 ?int $ averageHeartRate ,
107+ int $ minMovingTimeInSeconds ,
108+ int $ maxMovingTimeInSeconds ,
99109 ): self {
100110 return new self (
101111 lapId: $ lapId ,
@@ -111,6 +121,8 @@ public static function fromState(
111121 maxSpeed: $ maxSpeed ,
112122 elevationDifference: $ elevationDifference ,
113123 averageHeartRate: $ averageHeartRate ,
124+ minMovingTimeInSeconds: $ minMovingTimeInSeconds ,
125+ maxMovingTimeInSeconds: $ maxMovingTimeInSeconds ,
114126 );
115127 }
116128
@@ -197,6 +209,21 @@ public function getRelativePacePercentage(): float
197209 return round ($ relative , 2 );
198210 }
199211
212+ public function getRelativeMovingTimePercentage (): float
213+ {
214+ $ maxMovingTime = $ this ->getMaxMovingTimeInSeconds ();
215+
216+ if ($ maxMovingTime === 0 ) {
217+ return 0.0 ;
218+ }
219+
220+ $ movingTime = $ this ->getMovingTimeInSeconds ();
221+ $ relative = ($ movingTime / $ maxMovingTime ) * 100 ;
222+ $ relative = max (0 , min (100 , $ relative ));
223+
224+ return round ($ relative , 2 );
225+ }
226+
200227 public function getMinAverageSpeed (): MetersPerSecond
201228 {
202229 return $ this ->minAverageSpeed ;
@@ -222,6 +249,16 @@ public function getAverageHeartRate(): ?int
222249 return $ this ->averageHeartRate ;
223250 }
224251
252+ public function getMinMovingTimeInSeconds (): int
253+ {
254+ return $ this ->minMovingTimeInSeconds ;
255+ }
256+
257+ public function getMaxMovingTimeInSeconds (): int
258+ {
259+ return $ this ->maxMovingTimeInSeconds ;
260+ }
261+
225262 /**
226263 * @return array<string, mixed>
227264 */
0 commit comments