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

Allow a Run to be imported over the network #230

Merged
merged 2 commits into from
Mar 11, 2018

Conversation

jacobkiers
Copy link

In my use case, I cannot run a MongoDB installation close to my application, and saving and uploading files is hard.

Therefore, I have added the ability to have a profile uploaded. It uses the same process as the existing file importer in external/import.php file.

The corresponding PR for the collector is perftools/xhgui-collector#5.

Signed-off-by: Jacob Kiers <kiers@comandi.nl>
/**
* @var \Slim\Slim
*/
protected $_app;
Copy link
Contributor

Choose a reason for hiding this comment

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

Property name "$_app" should not be prefixed with an underscore to indicate visibility

Copy link
Author

Choose a reason for hiding this comment

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

I have used the same style as used elsewhere in the application.

Copy link
Member

Choose a reason for hiding this comment

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

There is some work to be done in order to get the code up to a PSR2 level.

Copy link
Author

Choose a reason for hiding this comment

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

Is that required for the passing of this PR? I kept as close to the original coding style as possible. I'm perfectly willing to bring the code that I've touched in line with PSR2.

However, adding "Upgrade the whole project to PSR-2" in the critical path would completely destroy the cost-benefit ratio of pursuing this PR.

Choose a reason for hiding this comment

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

You don't need to upgrade the entire project to PSR-2 but you should make sure your code changes pass the build and follow the chosen coding standards.

Copy link
Author

Choose a reason for hiding this comment

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

Fair enough. As I said: I'm perfectly willing to fix the code I touched.

Already did so, and also a few small other CS fixes. See the last commit.

/**
* @var Xhgui_Profiles
*/
private $_profiles;
Copy link
Contributor

Choose a reason for hiding this comment

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

Property name "$_profiles" should not be prefixed with an underscore to indicate visibility

Copy link
Author

Choose a reason for hiding this comment

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

I have used the same style as used elsewhere in the application.

/**
* @var Xhgui_WatchFunctions
*/
private $_watches;
Copy link
Contributor

Choose a reason for hiding this comment

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

Property name "$_watches" should not be prefixed with an underscore to indicate visibility

Copy link
Author

Choose a reason for hiding this comment

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

I have used the same style as used elsewhere in the application.

Copy link
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Is there any chance of getting a controller test for this new action? Having tests helps ensure that future changes don't accidentally break existing behavior.

{
$request = $this->_app->request();

$data = json_decode($request->getBody(), true);
Copy link
Member

Choose a reason for hiding this comment

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

There is no authentication, authorization or checksums on this data right now. Should there be?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I realize that. It was a conscious choice, since there were none of these in the rest of the project as well.

Furthermore, I assumed that XHGui, being a tool that is primarily used during development (imho), would be deployed in a somewhat trusted environment, like a staging server, or a developers' workstation.

@jacobkiers
Copy link
Author

I'm willing to add a test. What exactly would you like to see exactly in the test?

As said, I've essentially duplicated the code from external/import.php and added a route...

Signed-off-by: Jacob Kiers <kiers@comandi.nl>
@jacobkiers jacobkiers force-pushed the add-profile-import-over-network branch from bfaae2f to 9f99698 Compare February 2, 2018 19:11
@markstory
Copy link
Member

I'm willing to add a test. What exactly would you like to see exactly in the test?

That a JSON body can go in and be read out of the database. Having some tests around the API contract of the import endpoint would be nice.

As said, I've essentially duplicated the code from external/import.php and added a route...

This new endpoint gives us the opportunity to remove that file and have a better tested, more maintainable solution going forwards.

@jacobkiers
Copy link
Author

Hi, just quick note to assure you that I haven't forgotten about this. I'm currently unable to work on it, but I expect to be able to address the comments within a month.

@markstory markstory self-assigned this Feb 12, 2018
@markstory markstory merged commit c564cb3 into perftools:master Mar 11, 2018
@glensc
Copy link
Contributor

glensc commented Apr 19, 2020

This deserves an example of usage, i.e how to post to `/run/import' endpoint.

@glensc glensc mentioned this pull request Jun 19, 2020
@glensc
Copy link
Contributor

glensc commented Jul 9, 2020

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

5 participants