From d1f58e6f46ff26ab49480887c53e66da22811433 Mon Sep 17 00:00:00 2001 From: Yaros Date: Tue, 24 Mar 2026 15:08:46 +0100 Subject: [PATCH] refactor(server): use double --- .../openapi/lib/model/sync_asset_ocr_v1.dart | 40 +++++++++---------- open-api/immich-openapi-specs.json | 10 +++++ server/src/dtos/sync.dto.ts | 20 +++++----- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/mobile/openapi/lib/model/sync_asset_ocr_v1.dart b/mobile/openapi/lib/model/sync_asset_ocr_v1.dart index 62b4741b5b..d6d1e97962 100644 --- a/mobile/openapi/lib/model/sync_asset_ocr_v1.dart +++ b/mobile/openapi/lib/model/sync_asset_ocr_v1.dart @@ -33,7 +33,7 @@ class SyncAssetOcrV1 { String assetId; /// Confidence score of the bounding box - num boxScore; + double boxScore; /// OCR entry ID String id; @@ -45,31 +45,31 @@ class SyncAssetOcrV1 { String text; /// Confidence score of the recognized text - num textScore; + double textScore; /// Top-left X coordinate (normalized 0–1) - num x1; + double x1; /// Top-right X coordinate (normalized 0–1) - num x2; + double x2; /// Bottom-right X coordinate (normalized 0–1) - num x3; + double x3; /// Bottom-left X coordinate (normalized 0–1) - num x4; + double x4; /// Top-left Y coordinate (normalized 0–1) - num y1; + double y1; /// Top-right Y coordinate (normalized 0–1) - num y2; + double y2; /// Bottom-right Y coordinate (normalized 0–1) - num y3; + double y3; /// Bottom-left Y coordinate (normalized 0–1) - num y4; + double y4; @override bool operator ==(Object other) => identical(this, other) || other is SyncAssetOcrV1 && @@ -138,19 +138,19 @@ class SyncAssetOcrV1 { return SyncAssetOcrV1( assetId: mapValueOfType(json, r'assetId')!, - boxScore: num.parse('${json[r'boxScore']}'), + boxScore: (mapValueOfType(json, r'boxScore')!).toDouble(), id: mapValueOfType(json, r'id')!, isVisible: mapValueOfType(json, r'isVisible')!, text: mapValueOfType(json, r'text')!, - textScore: num.parse('${json[r'textScore']}'), - x1: num.parse('${json[r'x1']}'), - x2: num.parse('${json[r'x2']}'), - x3: num.parse('${json[r'x3']}'), - x4: num.parse('${json[r'x4']}'), - y1: num.parse('${json[r'y1']}'), - y2: num.parse('${json[r'y2']}'), - y3: num.parse('${json[r'y3']}'), - y4: num.parse('${json[r'y4']}'), + textScore: (mapValueOfType(json, r'textScore')!).toDouble(), + x1: (mapValueOfType(json, r'x1')!).toDouble(), + x2: (mapValueOfType(json, r'x2')!).toDouble(), + x3: (mapValueOfType(json, r'x3')!).toDouble(), + x4: (mapValueOfType(json, r'x4')!).toDouble(), + y1: (mapValueOfType(json, r'y1')!).toDouble(), + y2: (mapValueOfType(json, r'y2')!).toDouble(), + y3: (mapValueOfType(json, r'y3')!).toDouble(), + y4: (mapValueOfType(json, r'y4')!).toDouble(), ); } return null; diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index dc657ef005..5a52ffee6f 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -23125,6 +23125,7 @@ }, "boxScore": { "description": "Confidence score of the bounding box", + "format": "double", "type": "number" }, "id": { @@ -23141,38 +23142,47 @@ }, "textScore": { "description": "Confidence score of the recognized text", + "format": "double", "type": "number" }, "x1": { "description": "Top-left X coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "x2": { "description": "Top-right X coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "x3": { "description": "Bottom-right X coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "x4": { "description": "Bottom-left X coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "y1": { "description": "Top-left Y coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "y2": { "description": "Top-right Y coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "y3": { "description": "Bottom-right Y coordinate (normalized 0–1)", + "format": "double", "type": "number" }, "y4": { "description": "Bottom-left Y coordinate (normalized 0–1)", + "format": "double", "type": "number" } }, diff --git a/server/src/dtos/sync.dto.ts b/server/src/dtos/sync.dto.ts index 2673af36bb..27110694da 100644 --- a/server/src/dtos/sync.dto.ts +++ b/server/src/dtos/sync.dto.ts @@ -227,34 +227,34 @@ export class SyncAssetOcrV1 { @ApiProperty({ description: 'Asset ID' }) assetId!: string; - @ApiProperty({ description: 'Top-left X coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Top-left X coordinate (normalized 0–1)' }) x1!: number; - @ApiProperty({ description: 'Top-left Y coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Top-left Y coordinate (normalized 0–1)' }) y1!: number; - @ApiProperty({ description: 'Top-right X coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Top-right X coordinate (normalized 0–1)' }) x2!: number; - @ApiProperty({ description: 'Top-right Y coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Top-right Y coordinate (normalized 0–1)' }) y2!: number; - @ApiProperty({ description: 'Bottom-right X coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Bottom-right X coordinate (normalized 0–1)' }) x3!: number; - @ApiProperty({ description: 'Bottom-right Y coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Bottom-right Y coordinate (normalized 0–1)' }) y3!: number; - @ApiProperty({ description: 'Bottom-left X coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Bottom-left X coordinate (normalized 0–1)' }) x4!: number; - @ApiProperty({ description: 'Bottom-left Y coordinate (normalized 0–1)' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Bottom-left Y coordinate (normalized 0–1)' }) y4!: number; - @ApiProperty({ description: 'Confidence score of the bounding box' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Confidence score of the bounding box' }) boxScore!: number; - @ApiProperty({ description: 'Confidence score of the recognized text' }) + @ApiProperty({ type: 'number', format: 'double', description: 'Confidence score of the recognized text' }) textScore!: number; @ApiProperty({ description: 'Recognized text content' })