Merge pull request #987 from GSA/pr_debug_reports

add some debug around report generation
This commit is contained in:
Carlo Costino
2024-05-31 10:03:05 -04:00
committed by GitHub
2 changed files with 25 additions and 11 deletions

View File

@@ -64,7 +64,11 @@ def get_notification_by_id(notification_id):
@notifications.route("/notifications", methods=["GET"])
def get_all_notifications():
current_app.logger.debug("enter get_all_notifications()")
data = notifications_filter_schema.load(request.args)
current_app.logger.debug(
f"get_all_notifications() data {data} request.args {request.args}"
)
include_jobs = data.get("include_jobs", False)
page = data.get("page", 1)
@@ -96,19 +100,18 @@ def get_all_notifications():
notification.to = recipient
notification.normalised_to = recipient
return (
jsonify(
notifications=notification_with_personalisation_schema.dump(
pagination.items, many=True
),
page_size=page_size,
total=pagination.total,
links=pagination_links(
pagination, ".get_all_notifications", **request.args.to_dict()
),
result = jsonify(
notifications=notification_with_personalisation_schema.dump(
pagination.items, many=True
),
page_size=page_size,
total=pagination.total,
links=pagination_links(
pagination, ".get_all_notifications", **request.args.to_dict()
),
200,
)
current_app.logger.debug(f"result={result}")
return result, 200
@notifications.route("/notifications/<string:notification_type>", methods=["POST"])

View File

@@ -389,12 +389,17 @@ def get_service_history(service_id):
@service_blueprint.route("/<uuid:service_id>/notifications", methods=["GET", "POST"])
def get_all_notifications_for_service(service_id):
current_app.logger.debug("enter get_all_notifications_for_service")
if request.method == "GET":
data = notifications_filter_schema.load(request.args)
current_app.logger.debug(
f"use GET, request.args {request.args} and data {data}"
)
elif request.method == "POST":
# Must transform request.get_json() to MultiDict as NotificationsFilterSchema expects a MultiDict.
# Unlike request.args, request.get_json() does not return a MultiDict but instead just a dict.
data = notifications_filter_schema.load(MultiDict(request.get_json()))
current_app.logger.debug(f"use POST, request {request.get_json()} data {data}")
if data.get("to"):
notification_type = (
@@ -421,6 +426,10 @@ def get_all_notifications_for_service(service_id):
# for whether to show pagination links
count_pages = data.get("count_pages", True)
current_app.logger.debug(
f"get pagination with {service_id} service_id filters {data} \
limit_days {limit_days} include_jobs {include_jobs} include_one_off {include_one_off}"
)
pagination = notifications_dao.get_notifications_for_service(
service_id,
filter_dict=data,
@@ -462,6 +471,8 @@ def get_all_notifications_for_service(service_id):
notifications = notification_with_template_schema.dump(
pagination.items, many=True
)
current_app.logger.debug(f"number of notifications are {len(notifications)}")
current_app.logger.debug(f"first notification is {notifications[0]}")
# We try and get the next page of results to work out if we need provide a pagination link to the next page
# in our response if it exists. Note, this could be done instead by changing `count_pages` in the previous
# call to be True which will enable us to use Flask-Sqlalchemy to tell if there is a next page of results but