feat: Add automatic database consistency fix to furniture imports
CI / check (push) Successful in 28s
CI / release (push) Skipped
CI / deploy (push) Successful in 55s

- Added fixDatabaseConsistencyAfterImport() function in furni-import.ts
  * Fills empty catalog_name from items_base.public_name
  * Sets have_offer = '1' where it was '0'
  * Returns counts of fixes applied

- Integrated fix into import flows:
  * src/app/api/admin/import/furni/route.ts (single & batch POST)
  * src/app/api/admin/import/furni/batch/route.ts (SSE batch POST)

- API responses now include:
  * catalogNameFixed: number of catalog names filled
  * haveOfferFixed: number of have_offer values fixed

- Ensures 100% catalog_name coverage and have_offer=1 after every import
- Typecheck, lint, and all 827 tests pass
This commit is contained in:
openhands committed 2026-08-21 21:31:39 +02:00
1 parent b5c8a29956
commit 86f3d82c5d
3 files changed
+48

No files matched your search

@@ -13,6 +13,7 @@ import { buildLocalizedFurniDataFiles } from "@/lib/services/furni-data-i18n";
import {
ensureDirectories,
ensureFurniOwnership,
fixDatabaseConsistencyAfterImport,
importSingleFurni,
reconcileImportedOfferIds,
syncAssetsToGamedataBundle,
@@ -265,6 +266,9 @@ export const POST = withAdmin(
);
}
// Fix database consistency (catalog_name + have_offer) after import
const dbFix = await fixDatabaseConsistencyAfterImport();
send({
type: "batch_complete",
succeeded,
@@ -281,6 +285,8 @@ export const POST = withAdmin(
offerRebuildFixed,
spriteFixed,
interactionFixed,
catalogNameFixed: dbFix.catalogNameFixed,
haveOfferFixed: dbFix.haveOfferFixed,
languages,
duration: Date.now() - startTime,
});