diff --git a/frontend/src/pages/org/archived-item-detail/ui/qa.ts b/frontend/src/pages/org/archived-item-detail/ui/qa.ts index 3747ec90..c1f6ee80 100644 --- a/frontend/src/pages/org/archived-item-detail/ui/qa.ts +++ b/frontend/src/pages/org/archived-item-detail/ui/qa.ts @@ -44,7 +44,7 @@ import { formatNumber, getLocale } from "@/utils/localization"; import { pluralOf } from "@/utils/pluralize"; type QAStatsThreshold = { - lowerBoundary: `${number}` | "No data"; + lowerBoundary: `${number}`; count: number; }; type QAStats = Record<"screenshotMatch" | "textMatch", QAStatsThreshold[]>; @@ -505,9 +505,7 @@ export class ArchivedItemDetailQA extends TailwindElement {
- ${when( - qaRun.stats, - (stats) => html` -
- ${formatNumber(stats.done)} / ${formatNumber(stats.found)} - ${pluralOf("pages", stats.found)} ${msg("analyzed")} -
- `, - )} +
+ ${qaRun.state === "starting" + ? msg("Analysis starting") + : `${formatNumber(qaRun.stats.done)}/${formatNumber(qaRun.stats.found)} + ${pluralOf("pages", qaRun.stats.found)} ${msg("analyzed")}`} +
+ @@ -585,6 +582,7 @@ export class ArchivedItemDetailQA extends TailwindElement { ? this.renderMeter( qaRun.stats.found, this.qaStats.value.textMatch, + isRunning, ) : this.renderMeter()} @@ -613,16 +611,39 @@ export class ArchivedItemDetailQA extends TailwindElement { `; } - private renderMeter(pageCount?: number, barData?: QAStatsThreshold[]) { - if (pageCount === undefined || !barData) { + private renderMeter(): TemplateResult<1>; + private renderMeter( + pageCount: number, + barData: QAStatsThreshold[], + qaIsRunning: boolean | undefined, + ): TemplateResult<1>; + private renderMeter( + pageCount?: number, + barData?: QAStatsThreshold[], + qaIsRunning?: boolean, + ) { + if (!pageCount || !barData) { return html``; } + barData = barData.filter( + (bar) => (bar.lowerBoundary as string) !== "No data", + ); + + const analyzedPageCount = barData.reduce( + (prev, cur) => prev + cur.count, + 0, + ); + + const remainingPageCount = pageCount - analyzedPageCount; + const remainderBarLabel = qaIsRunning ? msg("Pending") : msg("Incomplete"); + + console.log({ pageCount, barData, analyzedPageCount }); return html` - + ${barData.map((bar) => { const threshold = qaStatsThresholds.find( ({ lowerBoundary }) => bar.lowerBoundary === lowerBoundary, @@ -632,23 +653,20 @@ export class ArchivedItemDetailQA extends TailwindElement { return bar.count !== 0 ? html`
- ${bar.lowerBoundary === "No data" - ? msg("No Data") - : threshold?.label} + ${threshold?.label}
- ${bar.lowerBoundary !== "No data" - ? html`${idx === 0 - ? `<${+qaStatsThresholds[idx + 1].lowerBoundary * 100}%` - : idx === qaStatsThresholds.length - 1 - ? `>=${threshold ? +threshold.lowerBoundary * 100 : 0}%` - : `${threshold ? +threshold.lowerBoundary * 100 : 0}-${+qaStatsThresholds[idx + 1].lowerBoundary * 100 || 100}%`} - match
` - : nothing} + ${idx === 0 + ? `<${+qaStatsThresholds[idx + 1].lowerBoundary * 100}%` + : idx === qaStatsThresholds.length - 1 + ? `>=${threshold ? +threshold.lowerBoundary * 100 : 0}%` + : `${threshold ? +threshold.lowerBoundary * 100 : 0}-${+qaStatsThresholds[idx + 1].lowerBoundary * 100 || 100}%`} + ${msg("match", { desc: "label for match percentage" })} +
${formatNumber(bar.count)} ${pluralOf("pages", bar.count)}
@@ -656,6 +674,24 @@ export class ArchivedItemDetailQA extends TailwindElement { ` : nothing; })} + ${remainingPageCount > 0 + ? html` + +
+ ${remainderBarLabel} +
+ ${formatNumber(remainingPageCount)} + ${pluralOf("pages", remainingPageCount)} +
+
+
+ ` + : nothing}
`; }