1

Page de statistiques

This commit is contained in:
2025-11-28 01:47:10 +01:00
parent 38926267a3
commit fd27dc7fb6
47 changed files with 3278 additions and 86 deletions

32
tools/lib/stats/python.js Normal file
View File

@@ -0,0 +1,32 @@
const { spawn } = require("child_process");
const path = require("path");
async function renderWithPython({ type, data, outputPath }) {
return new Promise((resolve, reject) => {
const scriptPath = path.resolve(__dirname, "../../render_stats_charts.py");
const child = spawn("python3", [scriptPath, "--type", type, "--output", outputPath], {
stdio: ["pipe", "inherit", "inherit"],
});
const payload = JSON.stringify(data);
child.stdin.write(payload);
child.stdin.end();
child.on("error", (error) => {
reject(error);
});
child.on("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Python renderer exited with code ${code}`));
}
});
});
}
module.exports = {
renderWithPython,
};