From 9e90923dd35fb2863737cf0f8d9b5519fa5f7e56 Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sun, 18 May 2025 23:00:20 +0200 Subject: [PATCH] now instead of sending status in two places, i'm just making the client ask for status --- public/js/index.js | 6 ++++++ src/routes/answers.py | 10 ---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 09ec2db..682d706 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -100,8 +100,12 @@ document.getElementById("upload-btn").onclick = async () => { commentResultsContainer.classList.add("hidden"); refinementResultsContainer.classList.add("hidden"); + uploadStatusEl.classList.remove("hidden"); uploadStatusEl.style.color = "green"; uploadStatusEl.textContent = json["id"]; + + uuid.value = json["id"]; + document.getElementById("request-status").click(); }; [...document.getElementsByClassName("download-results")].forEach((e) => { @@ -178,5 +182,7 @@ document.getElementById("request-status").onclick = async () => { if (json.type == "comment") populateCommentTable(json.results); else if (json.type == "comment") populateRefinementTable(json.results); else console.error(`Unknown type ${data.type}`); + } else if (json.status == "waiting") { + statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`; } }; diff --git a/src/routes/answers.py b/src/routes/answers.py index d1f5458..ac303ae 100644 --- a/src/routes/answers.py +++ b/src/routes/answers.py @@ -62,20 +62,10 @@ def handler(type_: str, validate_json: Callable, evaluate_submission: Callable): except InvalidJsonFormatError as e: return jsonify({'error': 'Invalid JSON format', 'message': str(e)}), 400 - socketio = current_app.extensions['socketio'] - sid = request.headers.get('X-Socket-Id') - socket_emit = functools.partial(socketio.emit, room=sid) - process_id = str(uuid.uuid4()) subject = Subject(process_id, type_, evaluate_submission) request2status[process_id] = subject - if sid: - socket_emit('successful-upload') - socket_emit('started-processing') - obs = SocketObserver(sid, socket_emit) - subject.registerObserver(obs) - QUEUE_MANAGER.submit(subject, validated) url = url_for(f".status", id=process_id, _external=True) return jsonify(