Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Remove face IDs that aren't associated with any cluster from getting added to the 'Only them' filter results

ashilkn472bf48b421d
diff --git a/mobile/lib/db/ml/db.dart b/mobile/lib/db/ml/db.dart
index d6566af3cb..8443c473af 100644
--- a/mobile/lib/db/ml/db.dart
+++ b/mobile/lib/db/ml/db.dart
@@ -1053,4 +1053,17 @@ class MLDataDB {
return <String>{for (final row in result) row[clusterIDColumn]};
}
+
+ Future<Set<int>> getAllFileIDsOfFaceIDsNotInAnyCluster() async {
+ final db = await instance.asyncDB;
+ final result = await db.getAll(
+ '''
+ SELECT DISTINCT file_id
+ FROM faces
+ LEFT JOIN face_clusters ON faces.face_id = face_clusters.face_id
+ WHERE face_clusters.face_id IS NULL;
+ ''',
+ );
+ return <int>{for (final row in result) row[fileIDColumn]};
+ }
}
diff --git a/mobile/lib/utils/hierarchical_search_util.dart b/mobile/lib/utils/hierarchical_search_util.dart
index 40c3507713..c8c3c11a81 100644
--- a/mobile/lib/utils/hierarchical_search_util.dart
+++ b/mobile/lib/utils/hierarchical_search_util.dart
@@ -103,6 +103,11 @@ Future<List<EnteFile>> getFilteredFiles(
final fileIDsToAvoid =
await MLDataDB.instance.getFileIDsOfClusterIDs(clusterIDsToAvoid);
+ final filesOfFaceIDsNotInAnyCluster =
+ await MLDataDB.instance.getAllFileIDsOfFaceIDsNotInAnyCluster();
+
+ fileIDsToAvoid.addAll(filesOfFaceIDsNotInAnyCluster);
+
final result =
intersectionOfSelectedFaceFiltersFileIDs.difference(fileIDsToAvoid);
filter.matchedUploadedIDs.addAll(result);