diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart index 03c4fc54cda3e5913467e1d41bdbef1066d9009d..2eb2ef02def0542e27d0499123b7906a1546a5c6 100644 --- a/mobile/lib/face/db.dart +++ b/mobile/lib/face/db.dart @@ -130,18 +130,12 @@ class FaceMLDataDB { /// Returns a map of fileID to the indexed ML version Future> getIndexedFileIds({int? minimumMlVersion}) async { final db = await instance.asyncDB; - late final String query; - if (minimumMlVersion != null) { - query = ''' - SELECT $fileIDColumn, $mlVersionColumn - FROM $facesTable - WHERE $mlVersionColumn >= $minimumMlVersion - '''; - } else { - query = ''' + String query = ''' SELECT $fileIDColumn, $mlVersionColumn FROM $facesTable '''; + if (minimumMlVersion != null) { + query += ' WHERE $mlVersionColumn >= $minimumMlVersion'; } final List> maps = await db.getAll(query); final Map result = {}; @@ -151,11 +145,14 @@ class FaceMLDataDB { return result; } - Future getIndexedFileCount() async { + Future getIndexedFileCount({int? minimumMlVersion}) async { final db = await instance.asyncDB; - final List> maps = await db.getAll( - 'SELECT COUNT(DISTINCT $fileIDColumn) as count FROM $facesTable', - ); + String query = + 'SELECT COUNT(DISTINCT $fileIDColumn) as count FROM $facesTable'; + if (minimumMlVersion != null) { + query += ' WHERE $mlVersionColumn >= $minimumMlVersion'; + } + final List> maps = await db.getAll(query); return maps.first['count'] as int; } diff --git a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart index 2fd9fd8fd7e135fe4272ae89e4327c66ef3cd3e8..d642b63636b8d85a60f260db973cf713e21505cb 100644 --- a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart +++ b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart @@ -1424,9 +1424,8 @@ class FaceMlService { indexableFiles.add(enteFile); } - final Map alreadyIndexedFiles = await FaceMLDataDB.instance - .getIndexedFileIds(minimumMlVersion: faceMlVersion); - final int alreadyIndexedCount = alreadyIndexedFiles.length; + final int alreadyIndexedCount = await FaceMLDataDB.instance + .getIndexedFileCount(minimumMlVersion: faceMlVersion); final int totalIndexableCount = indexableFiles.length; final ratio = alreadyIndexedCount / totalIndexableCount; w?.log('getIndexedDoneRatio');