File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
services/frontend/react_app/src/hooks Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,25 @@ export const useGetRequestArrival = (logs: Log[]) => {
1212 const parseDriverLogService = ( entry : LogEntry ) => {
1313 if ( entry . service !== 'driver' ) return ;
1414
15- const timeRegex = / ( \d + ) m ( \d + ) s / ;
16- const match = entry . status . match ( timeRegex ) ;
15+ const rawTimeMatch = entry . status . match ( / ( \d + m \d + s | \d + m | \d + s ) / ) ;
1716
18- if ( ! match ) return ;
17+ if ( ! rawTimeMatch ) return ; // No substring that looks like time
18+
19+ const rawTime = rawTimeMatch [ 0 ] ;
1920
20- const minutes = parseInt ( match [ 1 ] , 10 ) ;
21- const seconds = parseInt ( match [ 2 ] , 10 ) ;
21+ /**
22+ * Possible cases
23+ * 3m
24+ * 3m2s
25+ * 2s
26+ * */
27+ const timeRegex = / ^ (?: ( \d + ) m ) ? (?: ( \d + ) s ) ? $ / ;
28+ const match = rawTime . match ( timeRegex ) ;
29+
30+ if ( ! match ) return ;
2231
32+ const minutes = parseInt ( match [ 1 ] || '0' , 10 ) ;
33+ const seconds = parseInt ( match [ 2 ] || '0' , 10 ) ;
2334 return minutes * 60 + seconds ;
2435 } ;
2536
You can’t perform that action at this time.
0 commit comments