mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-26 08:09:51 -04:00
Disabled new endpoint as well
This commit is contained in:
@@ -113,46 +113,50 @@ def cancel_job(service_id, job_id):
|
||||
@user_has_permissions()
|
||||
def view_job_status_poll(service_id, job_id):
|
||||
"""
|
||||
Poll status endpoint using new lightweight cached API endpoint.
|
||||
Returns minimal data needed for polling.
|
||||
DISABLED: Lightweight polling endpoint no longer supported.
|
||||
Use manual page refresh instead.
|
||||
"""
|
||||
start_time = time.time()
|
||||
current_app.logger.info(f"Disabled lightweight polling endpoint accessed for job {job_id[:8]} - returning 410 Gone")
|
||||
abort(410, "Lightweight polling endpoint disabled. Please refresh the page manually.")
|
||||
|
||||
# Use new lightweight status endpoint
|
||||
try:
|
||||
status_data = job_api_client.get_job_status(service_id, job_id)
|
||||
|
||||
# Validate the response has expected fields
|
||||
required_fields = ["sent_count", "failed_count", "pending_count", "total_count", "processing_finished"]
|
||||
if all(key in status_data for key in required_fields):
|
||||
response_data = {
|
||||
"sent_count": status_data["sent_count"],
|
||||
"failed_count": status_data["failed_count"],
|
||||
"pending_count": status_data["pending_count"],
|
||||
"total_count": status_data["total_count"],
|
||||
"finished": status_data["processing_finished"],
|
||||
}
|
||||
processed_count = status_data["sent_count"] + status_data["failed_count"]
|
||||
else:
|
||||
current_app.logger.error(f"Status endpoint returned invalid response for job {job_id[:8]}: {status_data}")
|
||||
abort(500, "Invalid status response from API")
|
||||
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"Status endpoint failed for job {job_id[:8]}: {e}")
|
||||
abort(500, "Status endpoint unavailable")
|
||||
|
||||
response_time_ms = round((time.time() - start_time) * 1000, 2)
|
||||
response_json = json.dumps(response_data)
|
||||
response_size_bytes = len(response_json.encode("utf-8"))
|
||||
|
||||
current_app.logger.info(
|
||||
f"Poll status request - job_id={job_id[:8]} "
|
||||
f"response_size={response_size_bytes}b "
|
||||
f"response_time={response_time_ms}ms "
|
||||
f"progress={processed_count}/{response_data['total_count']}"
|
||||
)
|
||||
|
||||
return jsonify(response_data)
|
||||
# Original polling code - commented out for manual refresh mode
|
||||
# start_time = time.time()
|
||||
#
|
||||
# # Use new lightweight status endpoint
|
||||
# try:
|
||||
# status_data = job_api_client.get_job_status(service_id, job_id)
|
||||
#
|
||||
# # Validate the response has expected fields
|
||||
# required_fields = ["sent_count", "failed_count", "pending_count", "total_count", "processing_finished"]
|
||||
# if all(key in status_data for key in required_fields):
|
||||
# response_data = {
|
||||
# "sent_count": status_data["sent_count"],
|
||||
# "failed_count": status_data["failed_count"],
|
||||
# "pending_count": status_data["pending_count"],
|
||||
# "total_count": status_data["total_count"],
|
||||
# "finished": status_data["processing_finished"],
|
||||
# }
|
||||
# processed_count = status_data["sent_count"] + status_data["failed_count"]
|
||||
# else:
|
||||
# current_app.logger.error(f"Status endpoint returned invalid response for job {job_id[:8]}: {status_data}")
|
||||
# abort(500, "Invalid status response from API")
|
||||
#
|
||||
# except Exception as e:
|
||||
# current_app.logger.error(f"Status endpoint failed for job {job_id[:8]}: {e}")
|
||||
# abort(500, "Status endpoint unavailable")
|
||||
#
|
||||
# response_time_ms = round((time.time() - start_time) * 1000, 2)
|
||||
# response_json = json.dumps(response_data)
|
||||
# response_size_bytes = len(response_json.encode("utf-8"))
|
||||
#
|
||||
# current_app.logger.info(
|
||||
# f"Poll status request - job_id={job_id[:8]} "
|
||||
# f"response_size={response_size_bytes}b "
|
||||
# f"response_time={response_time_ms}ms "
|
||||
# f"progress={processed_count}/{response_data['total_count']}"
|
||||
# )
|
||||
#
|
||||
# return jsonify(response_data)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/jobs/<uuid:job_id>.json")
|
||||
|
||||
Reference in New Issue
Block a user