Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Minimum size argument for getting all cluster summaries

laurenspriema0502886b646
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index e45ea42523..5945175470 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -829,10 +829,14 @@ class FaceMLDataDB {
}
/// Returns a map of clusterID to (avg embedding, count)
- Future<Map<int, (Uint8List, int)>> clusterSummaryAll() async {
- final db = await instance.database;
+ Future<Map<int, (Uint8List, int)>> getAllClusterSummary([
+ int? minClusterSize,
+ ]) async {
+ final db = await instance.sqliteAsyncDB;
final Map<int, (Uint8List, int)> result = {};
- final rows = await db.rawQuery('SELECT * from $clusterSummaryTable');
+ final rows = await db.getAll(
+ 'SELECT * FROM $clusterSummaryTable${minClusterSize != null ? ' WHERE $countColumn >= $minClusterSize' : ''}',
+ );
for (final r in rows) {
final id = r[clusterIDColumn] as int;
final avg = r[avgColumn] as Uint8List;
diff --git a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
index 4cb9dce6c4..95497a90d2 100644
--- a/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
+++ b/mobile/lib/services/machine_learning/face_ml/feedback/cluster_feedback.dart
@@ -661,7 +661,7 @@ class ClusterFeedbackService {
);
final Map<int, (Uint8List, int)> clusterToSummary =
- await faceMlDb.clusterSummaryAll();
+ await faceMlDb.getAllClusterSummary();
final Map<int, (Uint8List, int)> updatesForClusterSummary = {};
final Map<int, List<double>> clusterAvg = {};
@@ -852,7 +852,7 @@ class ClusterFeedbackService {
// Get the cluster averages for the person's clusters and the suggestions' clusters
final Map<int, (Uint8List, int)> clusterToSummary =
- await faceMlDb.clusterSummaryAll();
+ await faceMlDb.getAllClusterSummary();
// Calculate the avg embedding of the person
final personClusters = await faceMlDb.getPersonClusterIDs(person.remoteID);