biep badabup fix #17 und sysinfos

Took 24 minutes
This commit is contained in:
Tobias Hopp 2023-02-06 21:26:29 +01:00
parent 053fd3e260
commit 00a53c05fb
3 changed files with 19 additions and 18 deletions

View File

@ -62,26 +62,28 @@ export class WebSocketHandler {
return new Promise(async resolve => { return new Promise(async resolve => {
let counts: any[] = []; let counts: any[] = [];
for (let drink of (await Drink.find())) { let drinks = await Drink.find();
// @ts-ignore for (let drink of drinks) {
console.log(drink._id);
console.log( (await Job.countDocuments( )) );
let count = await Job.countDocuments({drink: drink._id}); let count = await Job.countDocuments({drink: drink._id});
console.log(count);
counts.push([drink, count]); counts.push([drink, count]);
} }
counts.sort((a, b) => { counts = counts.sort((a, b) => {
// @ts-ignore if (a[1] > b[1])
if (a[1] < b[1])
return -1; return -1;
// @ts-ignore else if (a[1] < b[1])
else if (a[1] > b[1])
return 1; return 1;
else else
return 0; return 0;
}); });
console.debug(counts);
let stats = { let stats = {
"drinks_finished": (await Job.countDocuments({successful: true})), "drinks_finished": (await Job.countDocuments({successful: true})),
"drink_most": (counts.length == 0) ? "Keiner" : counts[0][0].name, "drink_most": (counts.length == 0) ? "Keiner" : counts[0][0].name,

View File

@ -328,6 +328,7 @@ router.ws('/', async (ws, req, next) => {
if (!net) if (!net)
net = nets["wlp0s20f3"]; net = nets["wlp0s20f3"];
let ipAddr: string = ""; let ipAddr: string = "";
if (net) if (net)
for (let addr of net) { for (let addr of net) {
if (addr.family == "IPv4" && addr.address && addr.address !== "127.0.0.1") if (addr.family == "IPv4" && addr.address && addr.address !== "127.0.0.1")
@ -336,12 +337,11 @@ router.ws('/', async (ws, req, next) => {
let packageJson = require('../../../package.json'); let packageJson = require('../../../package.json');
let wifi = (await exec("iwgetid")).stdout let wifi = (await exec("iwgetid")).stdout
if( !wifi || wifi.length == 0 ) if (!wifi || wifi.length == 0) {
{
wifi = ":Kein WiFi:"; wifi = ":Kein WiFi:";
} }
wifi.substring(wifi.indexOf('"') + 1, wifi.length - 2); wifi = wifi.substring(wifi.indexOf('"') + 1, wifi.length - 2);
let data = { let data = {
"internet": iTender.internetConnection, "internet": iTender.internetConnection,

View File

@ -106,7 +106,6 @@ function setupOnClickEvents() {
menuStatsBtn.onclick = async () => { menuStatsBtn.onclick = async () => {
let modal = new Modal("stats", "Statistiken"); let modal = new Modal("stats", "Statistiken");
let table = document.createElement("table"); let table = document.createElement("table");