Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions services/frontend/react_app/src/hooks/useGetRequestArrival.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@ export const useGetRequestArrival = (logs: Log[]) => {
const parseDriverLogService = (entry: LogEntry) => {
if (entry.service !== 'driver') return;

const timeRegex = /(\d+)m(\d+)s/;
const match = entry.status.match(timeRegex);
const rawTimeMatch = entry.status.match(/(\d+m\d+s|\d+m|\d+s)/);

if (!match) return;
if (!rawTimeMatch) return; // No substring that looks like time

const rawTime = rawTimeMatch[0];

const minutes = parseInt(match[1], 10);
const seconds = parseInt(match[2], 10);
/**
* Possible cases
* 3m
* 3m2s
* 2s
* */
const timeRegex = /^(?:(\d+)m)?(?:(\d+)s)?$/;
const match = rawTime.match(timeRegex);

if (!match) return;

const minutes = parseInt(match[1] || '0', 10);
const seconds = parseInt(match[2] || '0', 10);
return minutes * 60 + seconds;
};

Expand Down
Loading