Skip to content

Commit 551b1fc

Browse files
committed
chore: prettier 120 characters formatting changes
1 parent ee0d41c commit 551b1fc

26 files changed

+234
-546
lines changed

src/App.js

Lines changed: 41 additions & 125 deletions
Large diffs are not rendered by default.

src/App.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// src/App.test.js
2+
13
//import { render, screen } from "@testing-library/react";
24
//import App from "./App";
35

src/Dataframe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Dataframe.js
2+
* src/Dataframe.js
33
*
44
* JSON viewer for log entries. Clicking on a property _value_
55
* adds it to the log viewer.

src/HighVelocityJump.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/*
2-
* HighVelocityJump.js
3-
*
4-
* Representation of a HighVelocityJump
5-
*/
1+
// src/HighVelocityJump.js
2+
63
import _ from "lodash";
74
const velocityOutlier = 68; // true velocities higher than this unlikely (in Meters/sec aprrox 150 MPH)
85
import Stats from "./Stats";
@@ -21,11 +18,7 @@ class HighVelocityJump {
2118
lng: curLoc.rawlocation.longitude,
2219
});
2320

24-
const distanceTraveled =
25-
window.google.maps.geometry.spherical.computeDistanceBetween(
26-
startLoc,
27-
endLoc
28-
);
21+
const distanceTraveled = window.google.maps.geometry.spherical.computeDistanceBetween(startLoc, endLoc);
2922
const timeSpentMS = curEntry.date - prevEntry.date;
3023
const velocity = distanceTraveled / (timeSpentMS / 1000.0);
3124

@@ -95,9 +88,7 @@ class HighVelocityJump {
9588
const velocities = jumps.map((jump) => jump.velocity);
9689
const avgVelocity = _.mean(velocities);
9790
const medianVelocity = Stats.median(velocities);
98-
const stdDevVelocity = Math.sqrt(
99-
_.mean(velocities.map((v) => Math.pow(v - avgVelocity, 2)))
100-
);
91+
const stdDevVelocity = Math.sqrt(_.mean(velocities.map((v) => Math.pow(v - avgVelocity, 2))));
10192

10293
console.log("avgVelocity", avgVelocity);
10394
console.log("medianVelocity", medianVelocity);
@@ -107,15 +98,11 @@ class HighVelocityJump {
10798
// 1. Its velocity is greater than the median + 2 standard deviations
10899
// 2. OR its velocity is greater than velocityOutlier (150 MPH)
109100
// 3. AND the distance traveled is more than 1 meter
110-
const significantThreshold = Math.min(
111-
medianVelocity + 2 * stdDevVelocity,
112-
velocityOutlier
113-
);
101+
const significantThreshold = Math.min(medianVelocity + 2 * stdDevVelocity, velocityOutlier);
114102

115103
const significantJumps = jumps.filter(
116104
(jump) =>
117-
(jump.velocity > significantThreshold ||
118-
jump.velocity > velocityOutlier) &&
105+
(jump.velocity > significantThreshold || jump.velocity > velocityOutlier) &&
119106
jump.distanceTraveled > 1 &&
120107
jump.timeSpentMS > 0 // Ensure we're not dividing by zero
121108
);

src/LogTable.js

Lines changed: 30 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
/*
2-
* LogTable.js
3-
*
4-
* Handles the log viewing component.
5-
*/
1+
// src/LogTable.js
2+
63
import React, { useState } from "react";
74
import { useSortBy, useTable } from "react-table";
85
import { FixedSizeList as List } from "react-window";
96
import AutoSizer from "react-virtualized-auto-sizer";
107
import _ from "lodash";
118

12-
function Table({
13-
columns,
14-
data,
15-
onSelectionChange,
16-
listRef,
17-
selectedRow,
18-
centerOnLocation,
19-
}) {
20-
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } =
21-
useTable(
22-
{
23-
columns,
24-
data,
25-
autoResetSortBy: false,
26-
},
27-
useSortBy
28-
);
9+
function Table({ columns, data, onSelectionChange, listRef, selectedRow, centerOnLocation }) {
10+
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable(
11+
{
12+
columns,
13+
data,
14+
autoResetSortBy: false,
15+
},
16+
useSortBy
17+
);
2918

3019
const handleRowSelection = React.useCallback(
3120
(index, rowData) => {
@@ -60,25 +49,13 @@ function Table({
6049
};
6150

6251
const handleLongPress = () => {
63-
const lat = _.get(
64-
row.original,
65-
"lastlocationResponse.rawlocation.latitude"
66-
);
67-
const lng = _.get(
68-
row.original,
69-
"lastlocationResponse.rawlocation.longitude"
70-
);
52+
const lat = _.get(row.original, "lastlocationResponse.rawlocation.latitude");
53+
const lng = _.get(row.original, "lastlocationResponse.rawlocation.longitude");
7154
if (lat && lng && centerOnLocation) {
72-
console.log(
73-
"Calling centerOnLocation due to long press with:",
74-
lat,
75-
lng
76-
);
55+
console.log("Calling centerOnLocation due to long press with:", lat, lng);
7756
centerOnLocation(lat, lng);
7857
} else {
79-
console.log(
80-
"Unable to center: Invalid coordinates or centerOnLocation not available"
81-
);
58+
console.log("Unable to center: Invalid coordinates or centerOnLocation not available");
8259
}
8360
};
8461

@@ -137,16 +114,11 @@ function Table({
137114
<div {...getTableProps()}>
138115
<div>
139116
{headerGroups.map((headerGroup) => (
140-
<div
141-
{...headerGroup.getHeaderGroupProps()}
142-
className="logtable-header-row"
143-
>
117+
<div {...headerGroup.getHeaderGroupProps()} className="logtable-header-row">
144118
{headerGroup.headers.map((column) => (
145119
<div
146120
{...column.getHeaderProps()}
147-
className={`logtable-header-cell ${
148-
column.className || ""
149-
}`}
121+
className={`logtable-header-cell ${column.className || ""}`}
150122
style={{ width: column.width }}
151123
>
152124
{column.render("Header")}
@@ -180,9 +152,7 @@ function LogTable(props) {
180152
const [selectedRowIndex, setSelectedRowIndex] = useState(-1);
181153
const minTime = props.timeRange.minTime;
182154
const maxTime = props.timeRange.maxTime;
183-
const data = props.logData.tripLogs
184-
.getLogs_(new Date(minTime), new Date(maxTime))
185-
.value();
155+
const data = props.logData.tripLogs.getLogs_(new Date(minTime), new Date(maxTime)).value();
186156
const columnShortWidth = 50;
187157
const columnRegularWidth = 120;
188158
const columnLargeWidth = 150;
@@ -192,21 +162,15 @@ function LogTable(props) {
192162
{
193163
Header: "DayTime",
194164
accessor: "formattedDate",
195-
Cell: ({ cell: { value } }) =>
196-
value.substring(8, 10) + "T" + value.substring(11, 23),
165+
Cell: ({ cell: { value } }) => value.substring(8, 10) + "T" + value.substring(11, 23),
197166
width: columnRegularWidth,
198167
className: "logtable-cell",
199168
solutionTypes: ["ODRD", "LMFS"],
200169
},
201170
{
202171
Header: "Method",
203172
accessor: "@type",
204-
Cell: ({ cell: { value } }) => (
205-
<TrimCell
206-
value={value}
207-
trim="type.googleapis.com/maps.fleetengine."
208-
/>
209-
),
173+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="type.googleapis.com/maps.fleetengine." />,
210174
width: columnRegularWidth,
211175
className: "logtable-cell",
212176
solutionTypes: ["ODRD", "LMFS"],
@@ -228,9 +192,7 @@ function LogTable(props) {
228192
Header: "Sensor",
229193
accessor: "lastlocation.rawlocationsensor",
230194
id: "lastlocation_rawlocationsensor",
231-
Cell: ({ cell: { value } }) => (
232-
<TrimCell value={value} trim="LOCATION_SENSOR_" />
233-
),
195+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="LOCATION_SENSOR_" />,
234196
width: columnShortWidth,
235197
maxWidth: columnShortWidth,
236198
className: "logtable-cell",
@@ -240,9 +202,7 @@ function LogTable(props) {
240202
Header: "Location",
241203
accessor: "lastlocation.locationsensor",
242204
id: "lastlocation_locationsensor",
243-
Cell: ({ cell: { value } }) => (
244-
<TrimCell value={value} trim="_LOCATION_PROVIDER" />
245-
),
205+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="_LOCATION_PROVIDER" />,
246206
width: columnRegularWidth,
247207
className: "logtable-cell",
248208
solutionTypes: ["ODRD", "LMFS"],
@@ -266,19 +226,15 @@ function LogTable(props) {
266226
Header: "Vehicle State",
267227
accessor: "response.vehiclestate",
268228
id: "response_vehiclestate",
269-
Cell: ({ cell: { value } }) => (
270-
<TrimCell value={value} trim="VEHICLE_STATE_" />
271-
),
229+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="VEHICLE_STATE_" />,
272230
width: columnRegularWidth,
273231
className: "logtable-cell",
274232
solutionTypes: ["ODRD"],
275233
},
276234
{
277235
Header: "Task State",
278236
accessor: "response.state",
279-
Cell: ({ cell: { value } }) => (
280-
<TrimCell value={value} trim="TASK_STATE_" />
281-
),
237+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="TASK_STATE_" />,
282238
width: columnRegularWidth,
283239
className: "logtable-cell",
284240
solutionTypes: ["LMFS"],
@@ -287,9 +243,7 @@ function LogTable(props) {
287243
Header: "Trip Status",
288244
accessor: "response.tripstatus",
289245
id: "response_tripstatus",
290-
Cell: ({ cell: { value } }) => (
291-
<TrimCell value={value} trim="TRIP_STATUS_" />
292-
),
246+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="TRIP_STATUS_" />,
293247
width: columnLargeWidth,
294248
className: "logtable-cell",
295249
solutionTypes: ["ODRD"],
@@ -298,9 +252,7 @@ function LogTable(props) {
298252
Header: "Remaining tasks",
299253
id: "reamining_tasks",
300254
accessor: "response.remainingvehiclejourneysegments",
301-
Cell: ({ cell: { value } }) => (
302-
<>{value && _.sumBy(value, "stop.tasks.length")}</>
303-
),
255+
Cell: ({ cell: { value } }) => <>{value && _.sumBy(value, "stop.tasks.length")}</>,
304256
width: columnRegularWidth,
305257
className: "logtable-cell",
306258
solutionTypes: ["LMFS"],
@@ -323,9 +275,7 @@ function LogTable(props) {
323275
{
324276
Header: "Nav Status",
325277
accessor: "navStatus",
326-
Cell: ({ cell: { value } }) => (
327-
<TrimCell value={value} trim="NAVIGATION_STATUS_" />
328-
),
278+
Cell: ({ cell: { value } }) => <TrimCell value={value} trim="NAVIGATION_STATUS_" />,
329279
width: columnLargeWidth,
330280
className: "logtable-cell",
331281
solutionTypes: ["ODRD", "LMFS"],
@@ -348,8 +298,7 @@ function LogTable(props) {
348298
});
349299
const headers = [
350300
{
351-
Header:
352-
"Event Logs Table (click row to view full log entry and long click to also center map)",
301+
Header: "Event Logs Table (click row to view full log entry and long click to also center map)",
353302
columns: stdColumns,
354303
},
355304
];
@@ -367,9 +316,7 @@ function LogTable(props) {
367316
const focusOnRow = React.useCallback(
368317
(rowData) => {
369318
if (rowData && listRef.current) {
370-
const rowIndex = data.findIndex(
371-
(row) => row.timestamp === rowData.timestamp
372-
);
319+
const rowIndex = data.findIndex((row) => row.timestamp === rowData.timestamp);
373320
if (rowIndex !== -1) {
374321
listRef.current.scrollToItem(rowIndex, "center");
375322
setSelectedRowIndex(rowIndex);
@@ -404,6 +351,4 @@ const TrimCell = ({ value, trim }) => {
404351
return <>{value && value.replace(trim, "")}</>;
405352
};
406353

407-
export default React.forwardRef((props, ref) => (
408-
<LogTable {...props} ref={ref} />
409-
));
354+
export default React.forwardRef((props, ref) => <LogTable {...props} ref={ref} />);

src/MissingUpdate.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/*
2-
* MissingUpdate.js
3-
*
4-
* Representation of a missing update
5-
*/
1+
// src/MissingUpdate.js
2+
63
import _ from "lodash";
74
const updateOutlier = 60000; // 60 seconds
85
import Stats from "./Stats";

src/PolylineCreation.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// PolylineCreation.js
1+
// src/PolylineCreation.js
22

33
import { useState } from "react";
44
import { decode } from "s2polyline-ts";
@@ -35,14 +35,9 @@ function PolylineCreation({ onSubmit, onClose, buttonPosition }) {
3535
}
3636

3737
// Existing JSON parsing logic
38-
const jsonString = trimmedInput
39-
.replace(/(\w+):/g, '"$1":')
40-
.replace(/\s+/g, " ");
38+
const jsonString = trimmedInput.replace(/(\w+):/g, '"$1":').replace(/\s+/g, " ");
4139

42-
const inputWithBrackets =
43-
jsonString.startsWith("[") && jsonString.endsWith("]")
44-
? jsonString
45-
: `[${jsonString}]`;
40+
const inputWithBrackets = jsonString.startsWith("[") && jsonString.endsWith("]") ? jsonString : `[${jsonString}]`;
4641

4742
const waypoints = JSON.parse(inputWithBrackets);
4843

@@ -111,11 +106,7 @@ Or paste an encoded S2 polyline string`;
111106
<div style={{ margin: "5px" }}>
112107
<label>
113108
Color:
114-
<input
115-
type="color"
116-
value={color}
117-
onChange={(e) => setColor(e.target.value)}
118-
/>
109+
<input type="color" value={color} onChange={(e) => setColor(e.target.value)} />
119110
</label>
120111
</div>
121112
<div style={{ margin: "5px" }}>
@@ -133,11 +124,7 @@ Or paste an encoded S2 polyline string`;
133124
<button type="submit" className="map-button inner-button">
134125
Create Polyline
135126
</button>
136-
<button
137-
type="button"
138-
className="map-button inner-button"
139-
onClick={onClose}
140-
>
127+
<button type="button" className="map-button inner-button" onClick={onClose}>
141128
Close
142129
</button>
143130
</form>

0 commit comments

Comments
 (0)