Skip to content

Commit

Permalink
Merge pull request #1617 from chaoss/clean-up-visualization-error-del…
Browse files Browse the repository at this point in the history
…ivery

Visualization Error Delivery
  • Loading branch information
sgoggins committed Feb 14, 2022
2 parents 59c5fca + 170e5dd commit 0948e34
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 64 deletions.
55 changes: 33 additions & 22 deletions augur/routes/contributor_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,24 @@ def get_repo_id_start_date_and_end_date():
end_date = str(request.args.get('end_date', "{}-{}-{}".format(now.year, now.month, now.day)))

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

return None, None, None
if start_date < end_date:
return int(repo_id), start_date, end_date, None
else:

error = {
"message": "Invalid end_date. end_date is before the start_date",
"status_code": 400
}

return int(repo_id), None, None, error

else:
error = {
"message": "repo_id not specified. Use this endpoint to get a list of available repos: http://<your_host>/api/unstable/repos",
"status_code": 400
}
return None, None, None, error

def filter_out_repeats_without_required_contributions_in_required_time(repeat_list, repeats_df, required_time,
first_list):
Expand Down Expand Up @@ -573,13 +588,12 @@ def filter_data(df, needed_columns, not_null_columns=[]):
@server.app.route('/{}/contributor_reports/new_contributors_bar/'.format(server.api_version), methods=["GET"])
def new_contributors_bar():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

group_by, required_contributions, required_time = get_new_cntrb_bar_chart_query_params()

Expand Down Expand Up @@ -744,13 +758,12 @@ def new_contributors_bar():
methods=["GET"])
def new_contributors_stacked_bar():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

group_by, required_contributions, required_time = get_new_cntrb_bar_chart_query_params()

Expand Down Expand Up @@ -948,13 +961,12 @@ def new_contributors_stacked_bar():
methods=["GET"])
def returning_contributors_pie_chart():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

required_contributions = int(request.args.get('required_contributions', 4))
required_time = int(request.args.get('required_time', 365))
Expand Down Expand Up @@ -1081,13 +1093,12 @@ def returning_contributors_pie_chart():
methods=["GET"])
def returning_contributors_stacked_bar():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

group_by = str(request.args.get('group_by', "quarter"))
required_contributions = int(request.args.get('required_contributions', 4))
Expand Down
91 changes: 49 additions & 42 deletions augur/routes/pull_request_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,20 +437,34 @@ def get_repo_id_start_date_and_end_date():
end_date = str(request.args.get('end_date', "{}-{}-{}".format(now.year, now.month, now.day)))

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

return None, None, None
if start_date < end_date:
return int(repo_id), start_date, end_date, None
else:

error = {
"message": "Invalid end_date. end_date is before the start_date",
"status_code": 400
}

return int(repo_id), None, None, error

else:
error = {
"message": "repo_id not specified. Use this endpoint to get a list of available repos: http://<your_host>/api/unstable/repos",
"status_code": 400
}
return None, None, None, error

@server.app.route('/{}/pull_request_reports/average_commits_per_PR/'.format(server.api_version), methods=["GET"])
def average_commits_per_PR():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

group_by = str(request.args.get('group_by', "month"))
return_json = request.args.get('return_json', "false")
Expand Down Expand Up @@ -590,13 +604,12 @@ 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():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")

Expand Down Expand Up @@ -773,13 +786,12 @@ def average_comments_per_PR():
methods=["GET"])
def PR_counts_by_merged_status():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")

Expand Down Expand Up @@ -966,13 +978,12 @@ def PR_counts_by_merged_status():
methods=["GET"])
def mean_response_times_for_PR():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")

Expand Down Expand Up @@ -1266,13 +1277,12 @@ def add_legend(location, orientation, side):
methods=["GET"])
def mean_days_between_PR_comments():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")

Expand Down Expand Up @@ -1434,13 +1444,12 @@ def mean_days_between_PR_comments():
@server.app.route('/{}/pull_request_reports/PR_time_to_first_response/'.format(server.api_version), methods=["GET"])
def PR_time_to_first_response():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")
remove_outliers = str(request.args.get('remove_outliers', "true"))
Expand Down Expand Up @@ -1571,13 +1580,12 @@ def PR_time_to_first_response():
methods=["GET"])
def average_PR_events_for_closed_PRs():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

return_json = request.args.get('return_json', "false")
include_comments = str(request.args.get('include_comments', True))
Expand Down Expand Up @@ -1760,13 +1768,12 @@ def average_PR_events_for_closed_PRs():
@server.app.route('/{}/pull_request_reports/Average_PR_duration/'.format(server.api_version), methods=["GET"])
def Average_PR_duration():

repo_id, start_date, end_date = get_repo_id_start_date_and_end_date()
repo_id, start_date, end_date, error = get_repo_id_start_date_and_end_date()

if repo_id is None:
return Response(response="repo_id not specified. Use this endpoint to get a list of available repos: "
"http://<your_host>/api/unstable/repos",
if error:
return Response(response=error["message"],
mimetype='application/json',
status=400)
status=error["status_code"])

group_by = str(request.args.get('group_by', "month"))
return_json = request.args.get('return_json', "false")
Expand Down

0 comments on commit 0948e34

Please sign in to comment.