fix: harden furni import pipeline for production
- importSingleFurni: actually update an existing item instead of failing on a primary key INSERT collision; refuse to reassign a spriteId owned by a different classname - reconcileFurniDataWithItemsBase: also sync each entry's offerid to the DB sprite id, not just the id - Move the full-table interaction_modes_count verification out of the per-item import hot path and run it once per batch/single import - clone-import: apply the auto-detected interaction_type (was hardcoded 'default'), set FurnitureData offerid and catalog_items.offer_id to the new local sprite id (was the source hotel's id / -1) - clone batch route: run the same post-import reconcile/verify/ownership/RCON consolidation as the furni batch route - upload-import: set offer_id to the allocated id in both the direct insert and the generated SQL migration (was -1) - generateCatalogSql: use the classname as catalog_name and the item id as offer_id so rows match the app-managed import convention - stats + missing-nitro endpoints: match catalog membership via item_ids instead of the catalog_name join, so translated display names no longer break counts - deleteImportedItem/rollback: delete catalog rows by the canonical item_ids link only - classifyFurni: wall items always classify as 'walls' before prefix rules (rare_/val_/xmas_) can misfile them
This commit is contained in:
1 parent
2b9a015afb
commit
6021a91ef7
9 files changed
+162
-66
No files matched your search
@@ -447,6 +447,8 @@ export async function appendFurniEntriesBatch(
|
||||
export interface FurniDataReconcileResult {
|
||||
/** Entries whose stale spriteId was corrected to the DB id. */
|
||||
fixedIds: number;
|
||||
/** Entries whose stale offerid was corrected to the DB id. */
|
||||
fixedOfferIds: number;
|
||||
/** items_base rows with no matching furnitype entry (need re-import). */
|
||||
missing: number;
|
||||
/** spriteIds used by a different classname in the file; left untouched. */
|
||||
@@ -458,6 +460,8 @@ export interface FurniDataReconcileResult {
|
||||
* repair drift:
|
||||
* - an entry matching the classname but carrying a stale spriteId is updated
|
||||
* to the DB id (items_base is authoritative);
|
||||
* - the same is done for a stale `offerid`, which must equal the spriteId so
|
||||
* the emulator's catalog offer lookup stays in sync with the local ids;
|
||||
* - rows missing entirely from the file are counted (they need a re-import
|
||||
* or batch-regen, since building an entry requires the SWF/nitro metadata);
|
||||
* - genuine spriteId conflicts (id used by a different classname) are counted
|
||||
@@ -498,21 +502,33 @@ export async function reconcileFurniDataWithItemsBase(): Promise<FurniDataReconc
|
||||
}
|
||||
|
||||
let fixedIds = 0;
|
||||
let fixedOfferIds = 0;
|
||||
let missing = 0;
|
||||
let conflicts = 0;
|
||||
|
||||
const entryOfferId = (entry: Record<string, unknown>): number => {
|
||||
const v = Number(entry.offerid);
|
||||
return Number.isFinite(v) ? v : -1;
|
||||
};
|
||||
|
||||
for (const row of rows) {
|
||||
const spriteId = row.id;
|
||||
const existing = byId.get(spriteId);
|
||||
if (existing) {
|
||||
if (existing.entry.classname !== row.itemName) {
|
||||
conflicts++;
|
||||
} else if (entryOfferId(existing.entry) !== spriteId) {
|
||||
existing.entry.offerid = spriteId;
|
||||
fixedOfferIds++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const byName = byClass.get(row.itemName);
|
||||
if (byName) {
|
||||
byName.entry.id = spriteId;
|
||||
if (entryOfferId(byName.entry) !== spriteId) {
|
||||
byName.entry.offerid = spriteId;
|
||||
}
|
||||
byId.set(spriteId, byName);
|
||||
fixedIds++;
|
||||
} else {
|
||||
@@ -520,9 +536,9 @@ export async function reconcileFurniDataWithItemsBase(): Promise<FurniDataReconc
|
||||
}
|
||||
}
|
||||
|
||||
if (fixedIds > 0) {
|
||||
if (fixedIds > 0 || fixedOfferIds > 0) {
|
||||
await writeFurniData(furniData as Record<string, unknown>);
|
||||
}
|
||||
return { fixedIds, missing, conflicts };
|
||||
return { fixedIds, fixedOfferIds, missing, conflicts };
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user