From b109ca6f32e05184760b7017ea852caf59f9f68d Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 22 Aug 2026 11:32:13 +0200 Subject: [PATCH] fix: only create furniture-line pages for lines with enough items Add a LINE_PAGE_MIN_ITEMS threshold so small one-off lines collapse onto the category page instead of creating hundreds of tiny pages. --- src/lib/services/catalog-repair.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/lib/services/catalog-repair.ts b/src/lib/services/catalog-repair.ts index 10c316038e..19c1581573 100644 --- a/src/lib/services/catalog-repair.ts +++ b/src/lib/services/catalog-repair.ts @@ -513,6 +513,11 @@ export async function organizeCatalogAll(): Promise { .replace(/^_+|_+$/g, "") .slice(0, 40); + // Minimum number of items a furniture line must have before it gets its own + // dedicated catalog page. Lines below this threshold (one-off customs, etc.) + // collapse onto the category page so we don't create hundreds of tiny pages. + const LINE_PAGE_MIN_ITEMS = 3; + // Ensure a sub-page exists under the imported parent and return its id. const ensureSubPage = async ( captionSave: string, @@ -591,6 +596,20 @@ export async function organizeCatalogAll(): Promise { `)) as unknown as [Array<{ id: number }>, unknown]; const validPageIds = new Set(validPages.map((r) => Number(r.id))); + // Count items per furniture line so we only spin up a dedicated line page + // for lines that actually have enough items. Everything else falls back to + // the category page. + const lineCounts = new Map(); + for (const item of items) { + if (NO_CATALOG_KINDS.has(classifyCatalogItem(item))) continue; + const fl = resolveFurniline(item.item_name); + if (fl) lineCounts.set(fl, (lineCounts.get(fl) ?? 0) + 1); + } + const qualifyingLines = new Set(); + for (const [line, count] of lineCounts) { + if (count >= LINE_PAGE_MIN_ITEMS) qualifyingLines.add(line); + } + // Nitro presence (pets are purchasable without a furni .nitro bundle). const { nitroDir } = await getFurniAssetDirs(); const nitroFiles = await readdir(nitroDir).catch(() => [] as string[]); @@ -617,12 +636,12 @@ export async function organizeCatalogAll(): Promise { } // Target page: the item's furniture line (e.g. "weebz", "habbox") when - // known, otherwise its auto-detected category. The line page is created - // if it does not exist yet. + // it qualifies for its own page, otherwise its auto-detected category. + // The line page is created if it does not exist yet. let captionSave: string; let caption: string; const furniline = resolveFurniline(item.item_name); - if (furniline && slug(furniline)) { + if (furniline && slug(furniline) && qualifyingLines.has(furniline)) { captionSave = `imp_line_${slug(furniline)}`; caption = furniline; } else {