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

This commit is contained in:
ashilkn
2024-11-05 10:10:59 +05:30
parent fb9b3543e0
commit 472bf48b42
2 changed files with 18 additions and 0 deletions

View File

@@ -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]};
}
}

View File

@@ -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);