mirror of
https://github.com/karma-riuk/crab-webapp.git
synced 2025-07-05 06:08:13 +02:00
renamed uuid2subject to id2subject, since we don't
use uuid anymore
This commit is contained in:
@ -185,7 +185,7 @@ socket.on("queue_position", (data) => {
|
|||||||
let queue_position_interval = null;
|
let queue_position_interval = null;
|
||||||
|
|
||||||
document.getElementById("request-status").onclick = async () => {
|
document.getElementById("request-status").onclick = async () => {
|
||||||
if (!uuid.reportValidity()) return;
|
if (!id.reportValidity()) return;
|
||||||
const res = await fetch(`/answers/status/${uuid.value}`, {
|
const res = await fetch(`/answers/status/${uuid.value}`, {
|
||||||
headers: {
|
headers: {
|
||||||
"X-Socket-Id": socket.id,
|
"X-Socket-Id": socket.id,
|
||||||
@ -212,7 +212,7 @@ document.getElementById("request-status").onclick = async () => {
|
|||||||
} else if (json.status == "waiting") {
|
} else if (json.status == "waiting") {
|
||||||
statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`;
|
statusStatusEl.textContent = `Currently waiting, position in queue ${json.queue_position}`;
|
||||||
queue_position_interval = setInterval(() => {
|
queue_position_interval = setInterval(() => {
|
||||||
socket.emit("get_queue_position", { uuid: uuid.value });
|
socket.emit("get_queue_position", { id: uuid.value });
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -64,7 +64,7 @@ def handler(type_: str, validate_json: Callable, evaluate_submission: Callable):
|
|||||||
|
|
||||||
subject = Subject(type_, evaluate_submission)
|
subject = Subject(type_, evaluate_submission)
|
||||||
process_id = subject.id
|
process_id = subject.id
|
||||||
Subject.uuid2subject[process_id] = subject
|
Subject.id2subject[process_id] = subject
|
||||||
|
|
||||||
QUEUE_MANAGER.submit(subject, validated)
|
QUEUE_MANAGER.submit(subject, validated)
|
||||||
url = url_for(f".status", id=process_id, _external=True)
|
url = url_for(f".status", id=process_id, _external=True)
|
||||||
@ -91,10 +91,10 @@ def submit_comments(task):
|
|||||||
|
|
||||||
@router.route('/status/<id>')
|
@router.route('/status/<id>')
|
||||||
def status(id):
|
def status(id):
|
||||||
if id not in Subject.uuid2subject:
|
if id not in Subject.id2subject:
|
||||||
return jsonify({"error": "Id doens't exist", "message": f"Id {id} doesn't exist"}), 404
|
return jsonify({"error": "Id doens't exist", "message": f"Id {id} doesn't exist"}), 404
|
||||||
|
|
||||||
subject = Subject.uuid2subject[id]
|
subject = Subject.id2subject[id]
|
||||||
if subject.status == Status.COMPLETE:
|
if subject.status == Status.COMPLETE:
|
||||||
return jsonify({"status": "complete", "type": subject.type, "results": subject.results})
|
return jsonify({"status": "complete", "type": subject.type, "results": subject.results})
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ def init_socketio(app):
|
|||||||
@socketio.on('get_queue_position')
|
@socketio.on('get_queue_position')
|
||||||
def on_get_queue_position(data):
|
def on_get_queue_position(data):
|
||||||
sid = request.sid # type: ignore
|
sid = request.sid # type: ignore
|
||||||
subject_id = data["uuid"]
|
subject_id = data["id"]
|
||||||
subject = Subject.uuid2subject[subject_id]
|
subject = Subject.id2subject[subject_id]
|
||||||
if subject.status == Status.WAITING:
|
if subject.status == Status.WAITING:
|
||||||
return socketio.emit(
|
return socketio.emit(
|
||||||
'queue_position',
|
'queue_position',
|
||||||
|
@ -52,7 +52,7 @@ class SocketObserver(Observer):
|
|||||||
|
|
||||||
class Subject:
|
class Subject:
|
||||||
obs2subject: dict[Observer, "Subject"] = {}
|
obs2subject: dict[Observer, "Subject"] = {}
|
||||||
uuid2subject: dict[str, "Subject"] = {}
|
id2subject: dict[str, "Subject"] = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup(cls):
|
def setup(cls):
|
||||||
@ -69,7 +69,7 @@ class Subject:
|
|||||||
|
|
||||||
_, type_, _ = file.split("_")
|
_, type_, _ = file.split("_")
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
cls.uuid2subject[file] = Subject(
|
cls.id2subject[file] = Subject(
|
||||||
type_, lambda: None, id=file, status=Status.COMPLETE, results=json.load(f)
|
type_, lambda: None, id=file, status=Status.COMPLETE, results=json.load(f)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user