Took 25 minutes
This commit is contained in:
Tobias Hopp 2023-02-06 13:19:11 +01:00
parent 1794a147ac
commit e5cb1c87d1
2 changed files with 13 additions and 9 deletions

View File

@ -5,7 +5,6 @@ import {Settings} from "./Settings";
import Container from "./database/Container";
import Job from "./database/Job";
import Drink from "./database/Drink";
import {IDrink} from "./database/IDrink";
import Ingredient from "./database/Ingredient";
import {RequestType} from "./RequestType";
import debug from "debug";
@ -61,26 +60,31 @@ export class WebSocketHandler {
static sendStats() {
return new Promise(async resolve => {
let counts: IDrink[] = [];
let counts: any[] = [];
for (let drink of (await Drink.find())) {
// @ts-ignore
drink.count = (await Job.countDocuments({drink: drink}));
counts.push(drink)
let count = await Job.countDocuments({drink: drink._id});
counts.push([drink, count]);
}
counts.sort((a: IDrink, b: IDrink) => {
counts.sort((a, b) => {
// @ts-ignore
if (a.count < b.count)
if (a[1] < b[1])
return -1;
// @ts-ignore
else if (a.count > b.count)
else if (a[1] > b[1])
return 1;
else
return 0;
});
console.debug(counts);
let stats = {
"drinks_finished": (await Job.countDocuments({successful: true})),
"drink_most": (counts.length == 0) ? "Keiner" : counts[0].name,
"drink_most": (counts.length == 0) ? "Keiner" : counts[0][0].name,
"count_ingredients": (await Ingredient.countDocuments()),
"count_cocktails": (await Drink.countDocuments())
};

View File

@ -77,7 +77,7 @@ export class Fill {
let interval = setInterval(() => {
minus++;
if (minus + 1 > (job.estimatedTime as number)) {
clearInterval(interval);
setTimeout( () => clearInterval(interval), 1500 );
}
seconds.innerText = (Math.floor(job.estimatedTime as number - minus)) + "s";