-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug client: support stop ids in from / to inputs #6133
debug client: support stop ids in from / to inputs #6133
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #6133 +/- ##
=============================================
- Coverage 69.71% 69.71% -0.01%
+ Complexity 17698 17693 -5
=============================================
Files 2008 2008
Lines 75830 75827 -3
Branches 7764 7762 -2
=============================================
- Hits 52867 52862 -5
- Misses 20248 20255 +7
+ Partials 2715 2710 -5 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
I hope it won't be a big change, so it can be implemented in this pr. 🙂 I think I just need to write a |
@@ -29,6 +29,26 @@ export function SearchBar({ onRoute, tripQueryVariables, setTripQueryVariables, | |||
const [showServerInfo, setShowServerInfo] = useState(false); | |||
const target = useRef(null); | |||
|
|||
const setFromLocation = useCallback( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfectly fine pattern, but we have done it slightly differently - passing tripQueryVariables and setTripQueryVariables into the input components, and calling them there. I suggest keeping to this for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these functions to the LocationInputField
component.
0233a71
to
fdcd183
Compare
fdcd183
to
a96aba7
Compare
I implemented the I think it's not the frontend's job to decide, which query has to be called to resolve the coordinates, so it would be nice, if the graphql api has a generic place query, that resolves the coordinates for any id. What do you think about it? |
longitude, | ||
latitude, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My knowledge of JS is limited - but it looks like the arguments order is swapped according to the interface definition above. As a practice to avoid errors I like to always do lat, long
never long, lat
(doc, params, args, execution order and so on).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are named object properties, order actually doesn't matter. But I agree in principle to keep them consistently ordered anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the order of the params to follow the convention. (Although it wasn't a bug, because I used here the JavaScript's property shorthand syntax).
There are still unresolved issues in this PR imho. Maybe need to discuss in developer meeting? Although I'm unable to join until week after next week. |
a96aba7
to
17228b2
Compare
# Conflicts: # client/src/hooks/useTripQuery.ts
client/src/util/locationConverter.ts
Outdated
|
||
const LAT_LON_PATTERN = '(' + DOUBLE_PATTERN + ')(\\s*,\\s*|\\s+)(' + DOUBLE_PATTERN + ')'; | ||
|
||
const ID_SEPARATOR = ':'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took me a while to review this, but in the Transmodel API the IDs are not required to have a colon in it (although in practise they very often do).
Do we need the check for the valid feed id? We could simply say that if it's not a coordinate, then it's quay id, couldn't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the ID checking part, so any input, that not a valid coordinate pair is processed as an ID input.
On the other hand, I needed to implement error handling around the coordinate and trip plan query, because if the id was invalid, the queries threw an error. The simplest fix was a try-catch around them and an error console log (until a more precise error handling is implemented).
Does the Debug UI lookup stop by name and uses the coordinate for the plan/trip query? If so, that is not what we want - instead the ID of the stop should be used as input to the trip-query. There are differences in the logic on the server when coordinates are provided and stop/station/multi-modal-stops/group-of-stop-plases ids are provided. It is important to be able to test that. |
No, you have to paste the ID of the stop (not station) into the search bar. The lookup is necessary because we want to show a pin on the map, not because we want to know the name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried this and can't actually paste anything into the search bars. DOes it work for you, @richardkoszegi ?
Yes, it works for me. (I checked it in Chrome, Firefox, Opera, and Edge). Are the inputs not editable, or the query not runs automatically? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have been stupid. I cannot reproduce, so will approve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still comments that have not been addressed - EDIT: which may be because I didn't submit the review until now 🤦 sorry about that
longitude, | ||
latitude, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are named object properties, order actually doesn't matter. But I agree in principle to keep them consistently ordered anyway.
I tested this locally - seems to work as advertised! |
Summary
Added support for location ids in from/to fields in debug client.
Implementation Details:
locationConverter
: converts strings to Location objects and back based onLocationStringParser
class.LocationInputField
: a value state introduced for the input field. The newuseEffect
hook updates this state when location parameter changes. On theonBlur
event, this component fires the newonLocationChange
event if a valid location can be parsed from the input.SearchBar
: updatestripQueryVariables
based on the changed location.