diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart index 21d965e2b..2e07c56ac 100644 --- a/mobile/lib/face/db.dart +++ b/mobile/lib/face/db.dart @@ -124,11 +124,11 @@ class FaceMLDataDB { Future> clusterIdToFaceCount() async { final db = await instance.database; final List> maps = await db.rawQuery( - 'SELECT $cluserIDColumn, COUNT(*) as count FROM $facesTable where $cluserIDColumn IS NOT NULL GROUP BY $cluserIDColumn ', + 'SELECT $fcClusterID, COUNT(*) as count FROM $faceClustersTable where $fcClusterID IS NOT NULL GROUP BY $fcClusterID ', ); final Map result = {}; for (final map in maps) { - result[map[cluserIDColumn] as int] = map['count'] as int; + result[map[fcClusterID] as int] = map['count'] as int; } return result; } @@ -175,7 +175,7 @@ class FaceMLDataDB { }) async { final db = await instance.database; final List> maps = await db.rawQuery( - 'SELECT $faceEmbeddingBlob FROM $facesTable WHERE $cluserIDColumn = ? ${limit != null ? 'LIMIT $limit' : ''}', + 'SELECT $faceEmbeddingBlob FROM $facesTable WHERE $faceIDColumn in (SELECT $fcFaceId from $faceClustersTable where $fcClusterID = ?) ${limit != null ? 'LIMIT $limit' : ''}', [clusterID], ); return maps.map((e) => e[faceEmbeddingBlob] as Uint8List); @@ -250,9 +250,18 @@ class FaceMLDataDB { whereArgs: [clusterID], ); final List? faces = await getFacesForGivenFileID(recentFileID); + + if (clusterID == 1711967560179) { + debugPrint("faces: $faces"); + if (faces != null) { + debugPrint("faces: ${faces!.map((e) => e.faceID).toList()}"); + } + debugPrint('faceMaps $faceMaps'); + } if (faces != null) { for (final face in faces) { - if (faceMaps.any((element) => element[fcFaceId] == face.faceID)) { + if (faceMaps + .any((element) => (element[fcFaceId] as String) == face.faceID)) { return face; } } @@ -370,7 +379,7 @@ class FaceMLDataDB { // Query a batch of rows final List> maps = await db.query( facesTable, - columns: [faceIDColumn, faceClusterId, faceEmbeddingBlob], + columns: [faceIDColumn, faceEmbeddingBlob], where: '$faceScore > $minScore and $faceBlur > $minClarity', limit: batchSize, offset: offset, @@ -526,7 +535,7 @@ class FaceMLDataDB { final db = instance.database; return db.then((db) async { final List> maps = await db.rawQuery( - 'SELECT $clusterPersonTable.$cluserIDColumn, $fcFaceId FROM $faceClustersTable ' + 'SELECT $faceClustersTable.$fcClusterID, $fcFaceId FROM $faceClustersTable ' 'INNER JOIN $clusterPersonTable ' 'ON $faceClustersTable.$fcClusterID = $clusterPersonTable.$cluserIDColumn ' 'WHERE $clusterPersonTable.$personIdColumn = ?', diff --git a/mobile/lib/face/db_fields.dart b/mobile/lib/face/db_fields.dart index a4e249a97..ba21046aa 100644 --- a/mobile/lib/face/db_fields.dart +++ b/mobile/lib/face/db_fields.dart @@ -18,7 +18,6 @@ const createFacesTable = '''CREATE TABLE IF NOT EXISTS $facesTable ( $faceEmbeddingBlob BLOB NOT NULL, $faceScore REAL NOT NULL, $faceBlur REAL NOT NULL DEFAULT $kLapacianDefault, - $faceClusterId INTEGER, $mlVersionColumn INTEGER NOT NULL DEFAULT -1, PRIMARY KEY($fileIDColumn, $faceIDColumn) );