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
#2 Station search via device positioning services #79
Conversation
This is more a question for the Traewelling team: @HerrLevin @jeyemwey The variables and function names are partly written in correct CamelCase throughout the whole code (not just this PR), but sometimes with large letters at the beginning. I even found underlined names. It may make sense to standardize this, it doesn't look nice. |
@@ -42,6 +42,22 @@ public function TrainStationboard(Request $request) { | |||
); | |||
} | |||
|
|||
public function StationByCoordinates(Request $request) |
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 recommend renaming it "getStationByCoordinates", even if other method names are in this format. See my general answer to your pull request for further information.
@@ -42,6 +42,22 @@ public function TrainStationboard(Request $request) { | |||
); | |||
} | |||
|
|||
public function StationByCoordinates(Request $request) | |||
{ | |||
$NearestStation = TransportBackend::StationByCoordinates($request->latitude, $request->longitude); |
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 recommend renaming the variable to "$nearestStation"
@@ -169,7 +169,7 @@ class="fas fa-tools"></i> {{__('menu.admin')}}</a> | |||
<span class="footer-nav-link">/ <a href="{{ route('blog.all') }}">{{ __('menu.blog') }}</a></span> | |||
</p> | |||
<p class="mb-0">{!! __('menu.developed') !!}</p> | |||
<p class="mb-0">© 2019 Träwelling</p> | |||
<p class="mb-0">© 2020 Träwelling</p> |
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.
Maybe it would be better to change the year to {{date('Y')}} to prevent these changes.
Even if this is not the primary part of the PR.
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.
Hi @derheubi, thank you soo much for your contribution to Träwelling. I have posted a few remarks, but I'm sure those can be resolved quickly.
Can you (or someone from our core team) please add unit tests for the new Endpoint? I'm especially interested in edge cases like Null Island or the Poles, and far away places like New York, or Beijing. However, it is also possible to add valid tests like Berlin Hbf, Moskau Central or Frankfurt Flughafen Fernbf.
Route::get('/trains/nearby', [ | ||
'uses' => 'FrontendTransportController@StationByCoordinates', | ||
'as' => 'trains.nearby', | ||
]); | ||
|
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.
Can we add an API request for this? Then we need to adjust the swagger-api.yml
too. Maybe @HerrLevin can help? This is non-blocking from my side, and can be done later.
The question is, if it is of need to have unit tests for this. It's a core function of the db-rest API. Otherwise the db-rest API needs to be mocked and (I'm sorry :D) I have absolutely no idea how to do this in PHP. |
…ith nearby search and switching search time)
@@ -44,18 +44,20 @@ public function TrainStationboard(Request $request) { | |||
|
|||
public function StationByCoordinates(Request $request) | |||
{ | |||
$request->validate([ |
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.
You have to save the result from ->validate in an variable to use the validated input.
for example:
47: $validated = $request->validate([......
...
52: ....ates($validated['latitude'], $validated['longitude']);
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, my bad.
We do not use mocking for any of the API calls, if db-rest breaks, our CI is going down too. I can add the tests, if you want. |
That would be very nice! Maybe I can do the future upcoming unit tests on my own then 😅 |
Since we're planning to move the frontend to a JS-based API-client in the future, could you maybe implement this as an API-endpoint? |
For sure! I was looking at this topic anyway (it was mentioned by @jeyemwey in a review above) |
@HerrLevin I tried adding an API endpoint but actually I had no chance to test it (I get an error when sending an API request): I also added the endpoint to the api-swagger-v0.yml (swagger.io says, the configuration is valid) |
I have written some tests now for the frontend. @derheubi, can you check the "Allow edits from maintainers" checkbox? https://tighten.co/blog/adding-commits-to-a-pull-request/ |
Done |
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.
Looks good to me now.
Before merging: Can we speak about my comments about unified conventions? It's non blocking for me here, but it needs to be discussed. //Edit: Okay, 20 seconds too late. Merged. xD |
Sorry 😂 I have resolved tha sometimes, so there are only few issues left. |
This pull request implements the location-based search of the nearest station -> Issue #2
Therefore an extra button was added in the station input field:
When clicking the button the following will happen: