From f149156def309573cbce46baafa9a38c9e2966f4 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Tue, 15 Apr 2025 12:03:20 +1200 Subject: [PATCH] Indicate if stats are incomplete --- pug/includes/collection-stats.pug | 41 ++++++++++++++++++------------- routes/collection-stats.js | 4 ++- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/pug/includes/collection-stats.pug b/pug/includes/collection-stats.pug index 48b9e49..7f56878 100644 --- a/pug/includes/collection-stats.pug +++ b/pug/includes/collection-stats.pug @@ -4,13 +4,18 @@ input(type="hidden" name="account" value=account) button.s-link(hx-post="/api/load-collection" hx-target="#collection-sync" hx-select="#collection-sync" hx-include="previous input") Sync + if !hasFullTrackData && arrange !== "tag" + p.s-sidebarwidget--content + a.s-btn.s-btn__outlined.s-btn__muted(href="./" + and({arrange: "tag", shape: "grid"})) Download tags for more stats + table.s-sidebarwidget--content.s-sidebarwidget__items tr.s-sidebarwidget--item th items td= count.total - tr.s-sidebarwidget--item - th runtime - td= count.runtime + if hasFullTrackData + tr.s-sidebarwidget--item + th runtime + td= count.runtime tr.s-sidebarwidget--item th format td @@ -27,20 +32,22 @@ span.fc-black-250= ` / ` = count.paid span.fc-black-400= ` paid` - tr.s-sidebarwidget--item - th tracks - td - = count.tracks - span.pl8.fc-black-250= ` / ` - span.fc-black-400 avg #{count.avgTracks} - tr.s-sidebarwidget--item - th tags - td - = count.tags - span.pl8.fc-black-250= ` / ` - span.fc-black-400 avg #{count.avgTags} - span.fc-black-250= ` / ` - span.fc-black-400 lonely #{count.lonelyTags} + if hasFullTrackData + tr.s-sidebarwidget--item + th tracks + td + = count.tracks + span.pl8.fc-black-250= ` / ` + span.fc-black-400 avg #{count.avgTracks} + if hasFullTrackData + tr.s-sidebarwidget--item + th tags + td + = count.tags + span.pl8.fc-black-250= ` / ` + span.fc-black-400 avg #{count.avgTags} + span.fc-black-250= ` / ` + span.fc-black-400 lonely #{count.lonelyTags} tr.s-sidebarwidget--item th value td diff --git a/routes/collection-stats.js b/routes/collection-stats.js index 85e371f..8c95fca 100644 --- a/routes/collection-stats.js +++ b/routes/collection-stats.js @@ -58,7 +58,9 @@ pugSync.beforeInclude("includes/collection-stats.pug", async (from, event, {acco router.get("/:account/collection-stats", defineEventHandler(async event => { const {account} = await getValidatedRouterParams(event, schema.schema.account.parse) - return pugSync.render(event, "collection-stats.pug", {account, isStatsPage: true}) + // if there are any untagged items then we don't have full track data + const hasFullTrackData = !db.prepare("SELECT * FROM item LEFT JOIN item_tag USING (account, item_id) WHERE account = ? AND tag IS NULL").get(account) + return pugSync.render(event, "collection-stats.pug", {account, hasFullTrackData, isStatsPage: true}) })) router.post("/api/settings/currency", defineEventHandler(async event => {