comment out search for notification by to field

This commit is contained in:
Kenneth Kehl
2024-10-03 08:54:16 -07:00
parent 445a462b10
commit 76373de13b
+53 -53
View File
@@ -453,16 +453,16 @@ def get_all_notifications_for_service(service_id):
data = notifications_filter_schema.load(MultiDict(request.get_json())) data = notifications_filter_schema.load(MultiDict(request.get_json()))
current_app.logger.debug(f"use POST, request {request.get_json()} data {data}") current_app.logger.debug(f"use POST, request {request.get_json()} data {data}")
if data.get("to"): # if data.get("to"):
notification_type = ( # notification_type = (
data.get("template_type")[0] if data.get("template_type") else None # data.get("template_type")[0] if data.get("template_type") else None
) # )
return search_for_notification_by_to_field( # return search_for_notification_by_to_field(
service_id=service_id, # service_id=service_id,
search_term=data["to"], # search_term=data["to"],
statuses=data.get("status"), # statuses=data.get("status"),
notification_type=notification_type, # notification_type=notification_type,
) # )
page = data["page"] if "page" in data else 1 page = data["page"] if "page" in data else 1
page_size = ( page_size = (
data["page_size"] data["page_size"]
@@ -583,51 +583,51 @@ def get_notification_for_service(service_id, notification_id):
) )
def search_for_notification_by_to_field( # def search_for_notification_by_to_field(
service_id, search_term, statuses, notification_type # service_id, search_term, statuses, notification_type
): # ):
results = notifications_dao.dao_get_notifications_by_recipient_or_reference( # results = notifications_dao.dao_get_notifications_by_recipient_or_reference(
service_id=service_id, # service_id=service_id,
search_term=search_term, # search_term=search_term,
statuses=statuses, # statuses=statuses,
notification_type=notification_type, # notification_type=notification_type,
page=1, # page=1,
page_size=current_app.config["PAGE_SIZE"], # page_size=current_app.config["PAGE_SIZE"],
) # )
# We try and get the next page of results to work out if we need provide a pagination link to the next page # # 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. Note, this was previously be done by having # # in our response. Note, this was previously be done by having
# notifications_dao.dao_get_notifications_by_recipient_or_reference use count=False when calling # # notifications_dao.dao_get_notifications_by_recipient_or_reference use count=False when calling
# Flask-Sqlalchemys `paginate'. But instead we now use this way because it is much more performant for # # Flask-Sqlalchemys `paginate'. But instead we now use this way because it is much more performant for
# services with many results (unlike using Flask SqlAlchemy `paginate` with `count=True`, this approach # # services with many results (unlike using Flask SqlAlchemy `paginate` with `count=True`, this approach
# doesn't do an additional query to count all the results of which there could be millions but instead only # # doesn't do an additional query to count all the results of which there could be millions but instead only
# asks for a single extra page of results). # # asks for a single extra page of results).
next_page_of_pagination = notifications_dao.dao_get_notifications_by_recipient_or_reference( # next_page_of_pagination = notifications_dao.dao_get_notifications_by_recipient_or_reference(
service_id=service_id, # service_id=service_id,
search_term=search_term, # search_term=search_term,
statuses=statuses, # statuses=statuses,
notification_type=notification_type, # notification_type=notification_type,
page=2, # page=2,
page_size=current_app.config["PAGE_SIZE"], # page_size=current_app.config["PAGE_SIZE"],
error_out=False, # False so that if there are no results, it doesn't end in aborting with a 404 # error_out=False, # False so that if there are no results, it doesn't end in aborting with a 404
) # )
return ( # return (
jsonify( # jsonify(
notifications=notification_with_template_schema.dump( # notifications=notification_with_template_schema.dump(
results.items, many=True # results.items, many=True
), # ),
links=get_prev_next_pagination_links( # links=get_prev_next_pagination_links(
1, # 1,
len(next_page_of_pagination.items), # len(next_page_of_pagination.items),
".get_all_notifications_for_service", # ".get_all_notifications_for_service",
statuses=statuses, # statuses=statuses,
notification_type=notification_type, # notification_type=notification_type,
service_id=service_id, # service_id=service_id,
), # ),
), # ),
200, # 200,
) # )
@service_blueprint.route("/<uuid:service_id>/notifications/monthly", methods=["GET"]) @service_blueprint.route("/<uuid:service_id>/notifications/monthly", methods=["GET"])