Fixed image server sorting, fixed improper imstat job counts

This commit is contained in:
Essem 2022-01-05 10:17:59 -06:00
parent a9a404d1e1
commit 6d1bc63352
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
2 changed files with 3 additions and 3 deletions

View file

@ -18,7 +18,7 @@ class ImageStatsCommand extends Command {
for (let i = 0; i < servers.length; i++) { for (let i = 0; i < servers.length; i++) {
embed.embeds[0].fields.push({ embed.embeds[0].fields.push({
name: `Server ${i + 1}`, name: `Server ${i + 1}`,
value: `Running Jobs: ${servers[i].runningJobs}\nQueued: ${Math.max(0, servers[i].runningJobs - servers[i].max)}\nMax Jobs: ${servers[i].max}` value: `Running Jobs: ${Math.min(servers[i].runningJobs, servers[i].max)}\nQueued: ${Math.max(0, servers[i].runningJobs - servers[i].max)}\nMax Jobs: ${servers[i].max}`
}); });
} }
return embed; return embed;
@ -28,4 +28,4 @@ class ImageStatsCommand extends Command {
static aliases = ["imgstat", "imstats", "imgstats", "imstat"]; static aliases = ["imgstat", "imstats", "imgstats", "imstat"];
} }
export default ImageStatsCommand; export default ImageStatsCommand;

View file

@ -58,7 +58,7 @@ class ImageWorker extends BaseServiceWorker {
async chooseServer(ideal) { async chooseServer(ideal) {
if (ideal.length === 0) throw "No available servers"; if (ideal.length === 0) throw "No available servers";
const sorted = ideal.sort((a, b) => { const sorted = ideal.sort((a, b) => {
return b.load - a.load; return a.load - b.load;
}).filter((e, i, array) => { }).filter((e, i, array) => {
return !(e.load < array[0].load); return !(e.load < array[0].load);
}); });