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

Visualization - Error Checking #1610

Merged
merged 7 commits into from
Feb 7, 2022
Merged

Conversation

ABrain7710
Copy link
Contributor

@ABrain7710 ABrain7710 commented Feb 3, 2022

  1. Add method to get the repo_id, start_date, and end_date in the pr reports (this code was repeated for every single vis, so I made it into a method)
  2. Add a message to the user when they hit an endpoint, but do not specify a repo_id to show data for
  3. Change name of two methods in contributor reports, because they did not match the endpoint path

Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
…date

Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Signed-off-by: Andrew Brain <61482022+ABrain7710@users.noreply.github.com>
Copy link
Member

@sgoggins sgoggins left a comment

Choose a reason for hiding this comment

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

Not necessarily asking for changes. Except for one comment regarding whether or not we are changing the APIs to plural, everything else is to make sure I understand. I stopped commenting where they became repetitive in different endpoings.

I do think we'll need to provide legacy API endpoints if the pluralization is changing them because of the augur_view interface, as well as a series of Jupyter Notebooks being developed in the CHAOSS Metrics Models working group. (Every other tuesday at 6pm. Next meeting is February 15.) ... essentially, we have a "contract" with other developers that these endpoints will exist as they are. We don't even have to (and probably don't want to) document the old endpoints. We just want them to be "aliased" to the new ones, if that's a thing. Certainly better than redundant code, so I am hoping its a thing. "Feels" like its gotta be ...

@@ -356,11 +356,14 @@ def get_repo_id_start_date_and_end_date():

now = datetime.datetime.now()

repo_id = int(request.args.get('repo_id'))
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to remove the int cast? I have noticed sometimes python does not do type conversion the way we expect, though that's from APIs we pull from, not our own APIs. Just asking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If 'repo_id' is in the request.args array is None (which means it isn't specified in the query parameters), casting it to an int would result in an error because you cannot cast None to an int. Therefore I moved the cast to after I've checked if the 'repo_id' is specified in the request.args array

return repo_id, start_date, end_date
if repo_id:
return int(repo_id), start_date, end_date

Copy link
Member

Choose a reason for hiding this comment

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

is the none, none, none API return set what generates the "Hey, you need a repo ID there pardner?" message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, basically if the repo_id is not in the query params, then it returns None for all return variables. I could have just returned None, but I decided to still return None for the start_date and end_date too.

@@ -572,6 +575,12 @@ def new_contributors_bar():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()

if repo_id is None:
Copy link
Member

Choose a reason for hiding this comment

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

Seems to be "yes" to my prior question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@@ -931,10 +946,16 @@ def new_contributors_stacked_bar():

@server.app.route('/{}/contributor_reports/returning_contributors_pie_chart/'.format(server.api_version),
methods=["GET"])
def returning_contributor_pie_chart():
Copy link
Member

Choose a reason for hiding this comment

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

is this simply a convention change, or is It fixing an error. LGTM, I just want to make sure I understand the change.

Does it change the name of the existing endpoint? If so, @Ulincsys is relying on the current names and we probably need to also provide a legacy alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is simply a change to the method name to match the API endpoint path. It will not change the existing endpoint.

@@ -1058,10 +1079,16 @@ def returning_contributor_pie_chart():

@server.app.route('/{}/contributor_reports/returning_contributors_stacked_bar/'.format(server.api_version),
methods=["GET"])
def returning_contributor_stacked_bar():
def returning_contributors_stacked_bar():
Copy link
Member

Choose a reason for hiding this comment

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

Same note as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it is just a change so the method name matches the current API endpoint path


now = datetime.datetime.now()

repo_id = int(request.args.get('repo_id'))
Copy link
Member

Choose a reason for hiding this comment

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

Same question about int casting. I'm just asking to make sure I understand. My guess is you have tested it, and it is not necessary. So, then no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is casted in the return statement, after I've confirmed that it isn't a None type, because trying to cast a None type to int will return an error, and give the user a 500 server error

@@ -567,11 +590,14 @@ def average_commits_per_PR():
@server.app.route('/{}/pull_request_reports/average_comments_per_PR/'.format(server.api_version), methods=["GET"])
def average_comments_per_PR():

now = datetime.datetime.now()
Copy link
Member

Choose a reason for hiding this comment

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

What happens if somebody provides a start date, but not an end date? Is it defaulted to "now" elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone provides a start date but no end date, the end date defaults to now. This made me think that I should add an error check to make sure the start_date is before the end_date though.

@sgoggins sgoggins merged commit f03b97e into main Feb 7, 2022
@ABrain7710 ABrain7710 deleted the andrew-vis-reports-check-for-repo-id branch February 8, 2022 15:10
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

2 participants