Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] deal with existing cluster timelines in memory lane service

Priyanshu Dangareea02394d0d27
diff --git a/mobile/apps/photos/lib/db/ml/db.dart b/mobile/apps/photos/lib/db/ml/db.dart
index 3f6eb42af8..a7d5a1ddf6 100644
--- a/mobile/apps/photos/lib/db/ml/db.dart
+++ b/mobile/apps/photos/lib/db/ml/db.dart
@@ -22,7 +22,6 @@ import "package:photos/main.dart" show isProcessBg;
import "package:photos/models/ml/clip.dart";
import "package:photos/models/ml/face/face.dart";
import "package:photos/models/ml/face/face_with_embedding.dart";
-import "package:photos/models/ml/face/person.dart";
import "package:photos/models/ml/ml_versions.dart";
import "package:photos/models/ml/vector.dart";
import "package:photos/service_locator.dart";
@@ -2785,17 +2784,8 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
await db.execute(sql, params);
}
- Future<Set<String>> getClustersForMemoryLane(
- List<PersonEntity> persons,
- ) async {
+ Future<Set<String>> getClustersForMemoryLane(Set<String> assigned) async {
const batchSize = 256;
- final assigned = <String>{};
- for (final person in persons) {
- for (final cluster in person.data.assigned) {
- assigned.add(cluster.id);
- }
- }
-
final db = await asyncDB;
final clusters = <String>{};
var offset = 0;
diff --git a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
index 673ec6434e..c7407bd21d 100644
--- a/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
+++ b/mobile/apps/photos/lib/services/memory_lane/memory_lane_service.dart
@@ -113,7 +113,20 @@ class MemoryLaneService {
schedulePersonRecompute(person.remoteID, force: force);
}
if (flagService.internalUser) {
- _topNClusters = await _mlDataDB.getClustersForMemoryLane(persons);
+ _topNClusters = {};
+ final cache = await _cacheService.getCache();
+ for (final timeline in cache.allTimelines) {
+ if (timeline.isCluster) {
+ _topNClusters.add(timeline.personId);
+ }
+ }
+ final assigned = <String>{};
+ for (final person in persons) {
+ for (final cluster in person.data.assigned) {
+ assigned.add(cluster.id);
+ }
+ }
+ _topNClusters.addAll(await _mlDataDB.getClustersForMemoryLane(assigned));
for (final cluster in _topNClusters) {
schedulePersonRecompute(cluster, isCluster: true, force: force);
}