feat: add user lists statistic with donut chart

This commit is contained in:
Kentai Radiquum 2024-08-24 04:52:58 +05:00
parent 5c23f204da
commit 6e8f03e7b6
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
9 changed files with 276 additions and 35 deletions

View file

@ -172,18 +172,31 @@ export function sinceUnixDate(unixInSeconds: number) {
);
}
export function minutesToTime(min: number) {
export function minutesToTime(
min: number,
type?: "full" | "daysOnly" | "daysHours"
) {
const d = Math.floor(min / 1440); // 60*24
const h = Math.floor((min - d * 1440) / 60);
const m = Math.round(min % 60);
var dDisplay =
d > 0 ? `${d} ${numberDeclension(d, "день", "дня", "дней")}, ` : "";
d > 0 ? `${d} ${numberDeclension(d, "день", "дня", "дней")}` : "";
var hDisplay =
h > 0 ? `${h} ${numberDeclension(h, "час", "часа", "часов")}, ` : "";
h > 0 ? `${h} ${numberDeclension(h, "час", "часа", "часов")}` : "";
var mDisplay =
m > 0 ? `${m} ${numberDeclension(m, "минута", "минуты", "минут")}` : "";
return dDisplay + hDisplay + mDisplay;
if (type == "daysOnly") {
if (d > 0) return dDisplay;
return "? дней";
} else if (type == "daysHours") {
if (d > 0 && h > 0) return dDisplay + ", " + hDisplay;
if (h > 0) return hDisplay;
if (m > 0) return mDisplay;
} else {
return `${dDisplay}${h > 0 && ", " + hDisplay}${m > 0 && ", " + mDisplay}`;
}
}
const StatusList: Record<string, null | number> = {