added live update and file size to status
This commit is contained in:
1 parent
e5a0e942aa
commit
411ae23068
4 files changed
+214
-78
No files matched your search
@@ -1,4 +1,6 @@
|
||||
const { getDb } = require("../lib/mongo");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
exports.enqueue = async (req, res) => {
|
||||
try {
|
||||
@@ -120,7 +122,7 @@ exports.status = async (req, res) => {
|
||||
.find({})
|
||||
.sort({ failed_at: -1 })
|
||||
.toArray();
|
||||
|
||||
|
||||
res.render("status", {
|
||||
title: "Queue Status",
|
||||
queued,
|
||||
@@ -130,3 +132,56 @@ exports.status = async (req, res) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports.statusData = async (req, res) => {
|
||||
const db = await getDb();
|
||||
|
||||
const queued = await db.collection("queue")
|
||||
.find({ processing: { $ne: true } })
|
||||
.sort({ created_at: 1 })
|
||||
.toArray();
|
||||
|
||||
const processing = await db.collection("queue")
|
||||
.find({ processing: true })
|
||||
.sort({ created_at: 1 })
|
||||
.toArray();
|
||||
|
||||
const done = await db.collection("done")
|
||||
.find({})
|
||||
.sort({ finished_at: -1 })
|
||||
.toArray();
|
||||
|
||||
const failed = await db.collection("failed")
|
||||
.find({})
|
||||
.sort({ failed_at: -1 })
|
||||
.toArray();
|
||||
|
||||
|
||||
// ===========================
|
||||
// FILE SIZE FOR DONE
|
||||
// ===========================
|
||||
for (let job of done) {
|
||||
try {
|
||||
const filePath = path.join(process.env.OUTPUT_DIR, `${job.filename}.mp4`);
|
||||
const stats = fs.statSync(filePath);
|
||||
job.fileSize = stats.size;
|
||||
} catch {
|
||||
job.fileSize = null;
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================
|
||||
// FILE SIZE FOR PROCESSING
|
||||
// ===========================
|
||||
for (let job of processing) {
|
||||
try {
|
||||
const filePath = path.join(process.env.OUTPUT_DIR, `${job.filename}.mp4`);
|
||||
const stats = fs.statSync(filePath);
|
||||
job.fileSize = stats.size;
|
||||
} catch {
|
||||
job.fileSize = null;
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ queued, processing, done, failed });
|
||||
};
|
||||
Reference in new issue
Block a user