update
Took 25 minutes
This commit is contained in:
parent
1794a147ac
commit
e5cb1c87d1
@ -5,7 +5,6 @@ import {Settings} from "./Settings";
|
|||||||
import Container from "./database/Container";
|
import Container from "./database/Container";
|
||||||
import Job from "./database/Job";
|
import Job from "./database/Job";
|
||||||
import Drink from "./database/Drink";
|
import Drink from "./database/Drink";
|
||||||
import {IDrink} from "./database/IDrink";
|
|
||||||
import Ingredient from "./database/Ingredient";
|
import Ingredient from "./database/Ingredient";
|
||||||
import {RequestType} from "./RequestType";
|
import {RequestType} from "./RequestType";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
@ -61,26 +60,31 @@ export class WebSocketHandler {
|
|||||||
|
|
||||||
static sendStats() {
|
static sendStats() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let counts: IDrink[] = [];
|
|
||||||
|
let counts: any[] = [];
|
||||||
for (let drink of (await Drink.find())) {
|
for (let drink of (await Drink.find())) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
drink.count = (await Job.countDocuments({drink: drink}));
|
let count = await Job.countDocuments({drink: drink._id});
|
||||||
counts.push(drink)
|
counts.push([drink, count]);
|
||||||
}
|
}
|
||||||
counts.sort((a: IDrink, b: IDrink) => {
|
|
||||||
|
|
||||||
|
counts.sort((a, b) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (a.count < b.count)
|
if (a[1] < b[1])
|
||||||
return -1;
|
return -1;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
else if (a.count > b.count)
|
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].name,
|
"drink_most": (counts.length == 0) ? "Keiner" : counts[0][0].name,
|
||||||
"count_ingredients": (await Ingredient.countDocuments()),
|
"count_ingredients": (await Ingredient.countDocuments()),
|
||||||
"count_cocktails": (await Drink.countDocuments())
|
"count_cocktails": (await Drink.countDocuments())
|
||||||
};
|
};
|
||||||
|
@ -77,7 +77,7 @@ export class Fill {
|
|||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
minus++;
|
minus++;
|
||||||
if (minus + 1 > (job.estimatedTime as number)) {
|
if (minus + 1 > (job.estimatedTime as number)) {
|
||||||
clearInterval(interval);
|
setTimeout( () => clearInterval(interval), 1500 );
|
||||||
}
|
}
|
||||||
|
|
||||||
seconds.innerText = (Math.floor(job.estimatedTime as number - minus)) + "s";
|
seconds.innerText = (Math.floor(job.estimatedTime as number - minus)) + "s";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user