Skip to content
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

Merged
merged 10 commits into from Aug 4, 2020
Merged

#2 Station search via device positioning services #79

merged 10 commits into from Aug 4, 2020

Conversation

jheubuch
Copy link
Contributor

@jheubuch jheubuch commented Aug 3, 2020

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:
image

When clicking the button the following will happen:

  • if the user clicks the button the first time, he will be asked to grant the permission to use the positioning services
  • if the permission was granted and the positioning was successful, the most closest station will be queried and selected for the selections of the trains, buses etc
  • if the permission was denied, an error message will be displayed

@MrKrisKrisu
Copy link
Member

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)
Copy link
Member

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);
Copy link
Member

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"

app/Http/Controllers/TransportController.php Show resolved Hide resolved
app/Http/Controllers/TransportController.php Show resolved Hide resolved
resources/lang/de/stationboard.php Outdated Show resolved Hide resolved
@@ -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">&copy; 2019 Tr&auml;welling</p>
<p class="mb-0">&copy; 2020 Tr&auml;welling</p>
Copy link
Member

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.

jeyemwey
jeyemwey previously approved these changes Aug 3, 2020
Copy link
Collaborator

@jeyemwey jeyemwey left a 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.

app/Http/Controllers/FrontendTransportController.php Outdated Show resolved Hide resolved
Comment on lines +259 to +263
Route::get('/trains/nearby', [
'uses' => 'FrontendTransportController@StationByCoordinates',
'as' => 'trains.nearby',
]);

Copy link
Collaborator

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.

app/Http/Controllers/FrontendTransportController.php Outdated Show resolved Hide resolved
@jeyemwey jeyemwey self-requested a review August 3, 2020 15:03
@jeyemwey jeyemwey dismissed their stale review August 3, 2020 15:03

argh. Wrong button

@jheubuch
Copy link
Contributor Author

jheubuch commented Aug 4, 2020

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.

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.

@@ -44,18 +44,20 @@ public function TrainStationboard(Request $request) {

public function StationByCoordinates(Request $request)
{
$request->validate([
Copy link
Member

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']);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, my bad.

@jeyemwey
Copy link
Collaborator

jeyemwey commented Aug 4, 2020

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.

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.

@jheubuch
Copy link
Contributor Author

jheubuch commented Aug 4, 2020

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.

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 😅

@HerrLevin
Copy link
Member

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?
If not, that's no problem. It's just easier for us. 😅

@jheubuch
Copy link
Contributor Author

jheubuch commented Aug 4, 2020

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?
If not, that's no problem. It's just easier for us. 😅

For sure! I was looking at this topic anyway (it was mentioned by @jeyemwey in a review above)

@jheubuch
Copy link
Contributor Author

jheubuch commented Aug 4, 2020

@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):
image

I also added the endpoint to the api-swagger-v0.yml (swagger.io says, the configuration is valid)

@jeyemwey
Copy link
Collaborator

jeyemwey commented Aug 4, 2020

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/

@jheubuch
Copy link
Contributor Author

jheubuch commented Aug 4, 2020

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

Copy link
Collaborator

@jeyemwey jeyemwey left a 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.

@jeyemwey jeyemwey merged commit fcc4943 into Traewelling:develop Aug 4, 2020
@MrKrisKrisu
Copy link
Member

MrKrisKrisu commented Aug 4, 2020

Before merging: Can we speak about my comments about unified conventions?
@derheubi has used CamelCase Names which started with an uppercase letter. In the whole traewelling code there is no unified procedure for this. Sometimes there is a "getObject" or "ObjectName" Identifier.

It's non blocking for me here, but it needs to be discussed.

//Edit: Okay, 20 seconds too late. Merged. xD

@jeyemwey
Copy link
Collaborator

jeyemwey commented Aug 4, 2020

Sorry 😂 I have resolved tha sometimes, so there are only few issues left.

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.

None yet

4 participants