feat: standardize algorithm measurement results
This commit is contained in:
@@ -7,6 +7,11 @@ import { samplePointcloudFiles } from './pointcloudSample.js';
|
||||
import { forceReload as reloadPluginRegistry } from './plugins/registry.js';
|
||||
import { authenticateRequest } from './_core/auth.js';
|
||||
import { inspectPointcloudMetadata } from './pointcloudMetadata.js';
|
||||
import {
|
||||
inspectionObjectContextFromName,
|
||||
logCompatibilityWarnings,
|
||||
normalizeMeasurements,
|
||||
} from './measurementCompatibility.js';
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -562,18 +567,33 @@ router.post('/resync/analysis/:taskId/:resultId', requireFileWrite, async (req,
|
||||
try {
|
||||
const result = JSON.parse(fs.readFileSync(resultJsonPath, 'utf8'));
|
||||
const existingRd = (row.resultData as Record<string, unknown>) ?? {};
|
||||
const task = await db.getInspectionTaskById(taskId);
|
||||
const inspectionObject = task?.inspectionObjectId
|
||||
? await db.getInspectionObjectById(task.inspectionObjectId)
|
||||
: undefined;
|
||||
const normalized = normalizeMeasurements({
|
||||
pluginId: row.pluginId ?? (typeof existingRd.pluginId === 'string' ? existingRd.pluginId : undefined),
|
||||
measurements: result.measurements ?? existingRd.measurements,
|
||||
extra: result.extra ?? existingRd.extra,
|
||||
context: inspectionObjectContextFromName(inspectionObject?.name),
|
||||
algorithmProtocolVersion: result.schemaVersion ?? row.schemaVersion,
|
||||
});
|
||||
logCompatibilityWarnings(resultId, normalized.warnings);
|
||||
const mergedRd = {
|
||||
...existingRd,
|
||||
message: result.message ?? existingRd.message,
|
||||
measurements: result.measurements ?? existingRd.measurements,
|
||||
measurements: normalized.measurements,
|
||||
errorStats: result.errorStats ?? existingRd.errorStats,
|
||||
overlay3d: result.overlay3d ?? existingRd.overlay3d,
|
||||
images: result.images ?? existingRd.images,
|
||||
files: result.files ?? existingRd.files,
|
||||
extra: result.extra ?? existingRd.extra,
|
||||
extra: normalized.extra,
|
||||
schemaVersion: result.schemaVersion ?? existingRd.schemaVersion,
|
||||
};
|
||||
await db.updateTaskAnalysisResult(resultId, { resultData: mergedRd });
|
||||
await db.updateTaskAnalysisResult(resultId, {
|
||||
measurements: normalized.measurements,
|
||||
resultData: mergedRd,
|
||||
});
|
||||
res.json({ success: true, overlay3d: result.overlay3d });
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: String(e) });
|
||||
|
||||
Reference in New Issue
Block a user