Skip to content

Commit

Permalink
Fixes for no shape_dist_traveled
Browse files Browse the repository at this point in the history
  • Loading branch information
brendannee committed Aug 17, 2021
1 parent df7781a commit 253bb78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Format a route name.
*/
export function formatRouteName(route) {
if (route.route_short_name !== '' && route.route_short_name !== undefined) {
if (route.route_short_name !== '' && route.route_short_name !== null) {
return route.route_short_name;
}

Expand Down
5 changes: 2 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const getStationsFromTrip = async trip => {
let previousStationCoordinates;
return trip.stoptimes.map((stoptime, index) => {
const stop = stops[index];
const hasShapeDistance = every(trip.stoptimes, stoptime => stoptime.shape_dist_traveled !== undefined);
const hasShapeDistance = every(trip.stoptimes, stoptime => stoptime.shape_dist_traveled !== null);

if (!hasShapeDistance) {
if (index === 0) {
Expand Down Expand Up @@ -171,8 +171,7 @@ const getDataforChart = async (config, routeId) => {

stations = [...stations, ...stationsOppositeDirection];
}

const hasShapeDistance = every(longestTrip.stoptimes, stoptime => stoptime.shape_dist_traveled !== undefined);
const hasShapeDistance = every(longestTrip.stoptimes, stoptime => stoptime.shape_dist_traveled !== null);
if (!hasShapeDistance) {
notes.push('Distance between stops calculated assuming a straight line.');
}
Expand Down
6 changes: 3 additions & 3 deletions views/chart/formatting_functions.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
} = route;
let routeName = '';
if (shortName !== '' && shortName !== undefined) {
if (shortName !== '' && shortName !== null) {
routeName += shortName;
}
if (shortName !== '' && shortName !== undefined && longName !== '' && longName !== undefined) {
if (shortName !== '' && shortName !== null && longName !== '' && longName !== null) {
routeName += ' - ';
}
if (longName !== '' && longName !== undefined) {
if (longName !== '' && longName !== null) {
routeName += longName;
}
Expand Down

0 comments on commit 253bb78

Please sign in to comment.