Skip to content

Conversation

robertgregg3
Copy link

@robertgregg3 robertgregg3 commented May 6, 2021

Relating to #663

  • Added the new location types to gtfs.yml
  • Added validation if one or more agencies exists to add an Agency ID
  • Added conditional validation to stop_lat and stop_lng to be required if the location type has a value of 2 or more

Also fix #716, fix #717.

@robertgregg3
Copy link
Author

robertgregg3 commented May 6, 2021

This is a first draft at the changes, so there are a few console logs and other bits I will remove when completed. Just wanted to see if I was on the right track, and I have a few questions:

  1. I am getting a linting error on line 198 "Expected a 'break' statement before 'case'". I'm not sure why
  2. On line 259 it looks like an attempt to validate the agency ID, so is it worth removing that one? Or is that for a different case?

case 'GTFS_AGENCY':
if (
name === 'agency_id' &&
agencies.length > 1
) {
if (valueDoesNotExist) {
return {
field: name,
invalid: true,
reason: 'Field must be populated for feeds with more than one agency.'
}
}
}

@binh-dam-ibigroup
Copy link
Contributor

This is a first draft at the changes and I have a few questions:

  1. I am getting a linting error on line 198 "Expected a 'break' statement before 'case'". I'm not sure why
  2. On line 259 it looks like an attempt to validate the agency ID, so is it worth removing that one? Or is that for a different case?

case 'GTFS_AGENCY':
if (
name === 'agency_id' &&
agencies.length > 1
) {
if (valueDoesNotExist) {
return {
field: name,
invalid: true,
reason: 'Field must be populated for feeds with more than one agency.'
}
}
}

@robertgregg3 Not all paths in that case statement lead to a return if you take a closer look!

Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some bits of logic I am not sure to follow. If I got it wrong, then a code comment would help people follow the reasoning. Also see my refactoring suggestions so far and my comment for making the lint check pass.

Comment on lines 104 to 105
console.log(idList.length)
console.log({entity})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove console statements.

)
console.log(idList.length)
console.log({entity})
if (agencies.length > 1 && entity.agency_id === null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using valueDoesNotExist, isOptionalAndEmpty defined for the function that already checked for null/undefined/empty string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Comment on lines 185 to 188
if (isNotLat) {
reason = 'Field must be valid latitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the range check from isNotLat be enforced here regardless of stop type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@binh-dam-ibigroup it is being enforced regardless. Line 189 is the conditional for the location_type:

image

reason = 'Field must be valid latitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLat, reason}
}
if (entity && entity.location_type >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= 2 rather?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! 🤦‍♂️

reason = 'Field must be valid longitude.'
return {field: name, invalid: isOptionalAndEmpty || isNotLng, reason}
}
if (entity && entity.location_type >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= 2 instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! 🤦‍♂️

}
if (entity && entity.location_type >= 2) {
if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove leading 1

}
if (entity && entity.location_type >= 2) {
if (isOptionalAndEmpty) {
reason = '1 Latitude and Longitude are required for your current location type'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove leading 1

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2021

Codecov Report

Merging #668 (ef69da3) into dev (4e7b8ea) will increase coverage by 0.00%.
The diff coverage is 18.91%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #668   +/-   ##
=======================================
  Coverage   15.68%   15.68%           
=======================================
  Files         329      329           
  Lines       16797    16823   +26     
  Branches     5062     5071    +9     
=======================================
+ Hits         2634     2639    +5     
- Misses      12113    12133   +20     
- Partials     2050     2051    +1     
Flag Coverage Δ
unit_tests 15.68% <18.91%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/editor/components/pattern/PatternStopCard.js 0.00% <0.00%> (ø)
lib/editor/util/map.js 38.51% <ø> (ø)
lib/gtfs/util/index.js 4.34% <ø> (ø)
lib/types/index.js 0.00% <ø> (ø)
lib/editor/util/validation.js 45.00% <41.17%> (+2.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e7b8ea...ef69da3. Read the comment docs.

return {field: name, invalid: isNotLat, reason}
}
if (entity && entity.location_type >= 2) {
if (!locationType || locationType < 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the GTFS reference for the location types, I think the condition should be <= 2: https://developers.google.com/transit/gtfs/reference#stopstxt

Rob Gregg added 3 commits May 11, 2021 15:10
@binh-dam-ibigroup binh-dam-ibigroup removed their assignment May 11, 2021
@binh-dam-ibigroup
Copy link
Contributor

Reassign and request reviews when done, thanks!

Rob Gregg added 2 commits June 1, 2021 16:47
….js): Update to the GTFS Spec U

Added the changes where applicable to the gtfs.yml file. Added the new types for continuous drop
off/pick up and added fields as well as basic validation in the patternStopCard file.

BREAKING CHANGE: There have been added fields that need to coincide with changes on the backend as
the api will be looking for the new fields and those fields need to be present on the Front end

#663
@binh-dam-ibigroup
Copy link
Contributor

@robertgregg3 there are still build errors, could you fix them, please?

Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like my previous comment regarding enforcing lat/lon values even for stop types that don't require it was not resolved? Also, the build needs to be fixed, and some long lines need to be broken out.

* Returns false if the value is ok.
* Returns an EditorValidationIssue object if the value is not ok.
*/
// eslint-disable-next-line complexity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an error-level eslint rule with our eslint config, however, I think there is a lot of value in having it warn the developer because having functions with tons of complexity will make code very difficult to read and maintain in the future. It's not your fault that this method is bloated in the first place, but it will significantly improve the future readability and maintainability of this code to refactor this method into smaller chunks right now.

Changed wheelchairBoarding to a string. Added continuous fields to the map.js.

#663
@robertgregg3 robertgregg3 changed the title Updates to agency.txt and stops.txt spec changes Updates to gtfs spec changes - front end UI fields only Jun 2, 2021
Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See formatting and refactoring suggestions.

componentClass='select'
placeholder='select'
disabled={hasShapeId}
defaultValue={1}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultValue is no longer needed (we set the value prop instead). (Also, sort props alphabetically)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Thanks.

</FormGroup>
</Col>
<Col xs={6}>
<FormGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend extracting this <FormGroup> and its contents into a component and reuse in all 4 instances.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good idea!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any progress on this one, by curiosity?

Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation of stop_name is interfering with editing of stop data on existing feeds.

@robertgregg3 robertgregg3 removed their assignment Aug 2, 2021
@binh-dam-ibigroup binh-dam-ibigroup self-assigned this Sep 9, 2021
Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, sorry it fell off the radar due to lack of assignment.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go after addressing this comment: #668 (comment)

@binh-dam-ibigroup binh-dam-ibigroup added the BLOCKED Blocked (waiting on another PR to be merged) label Sep 21, 2021
@binh-dam-ibigroup
Copy link
Contributor

Blocking this PR pending resolution of #716, #717 that it introduced.

@binh-dam-ibigroup binh-dam-ibigroup dismissed landonreed’s stale review September 21, 2021 14:20

Requested changes were added from #690.

@binh-dam-ibigroup binh-dam-ibigroup removed the BLOCKED Blocked (waiting on another PR to be merged) label Sep 23, 2021
@binh-dam-ibigroup binh-dam-ibigroup merged commit c8a7c82 into dev Sep 23, 2021
@miles-grant-ibigroup miles-grant-ibigroup deleted the gtfs-spec-changes branch November 10, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error saving feed info after GTFS 2.0 update Error saving patterns/timetables after backend update for GTFS 2.0
7 participants