created a websocket to witness the progress of the processing

This commit is contained in:
Karma Riuk
2025-05-07 17:29:21 +02:00
parent 3c9ab4c4be
commit 21735a236a
8 changed files with 96 additions and 9 deletions

29
src/utils/process_data.js Normal file
View File

@ -0,0 +1,29 @@
import { io as socket } from "../socket.js";
export const evaluate_comments = async (answers) => {
const total = Object.keys(answers).length;
let i = 0;
for (const [key, value] of Object.entries(answers)) {
console.log(`Processing ${key}: ${value}...`);
await new Promise((res) => setTimeout(res, 500));
console.log("Done");
const data = {
percent: Math.floor((++i / total) * 100),
};
socket.emit("progress", data);
}
};
export const evaluate_refinement = async (answers) => {
const total = Object.keys(answers).length;
let i = 0;
for (const [key, value] of Object.entries(answers)) {
console.log(`Processing ${key}: ${value}...`);
await new Promise((res) => setTimeout(res, 500));
console.log("Done");
const data = {
percent: Math.floor((++i / total) * 100),
};
socket.emit("progress", data);
}
};