From 8079d44c68070f1eaedc365205b64b6f475f1230 Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Mon, 8 Sep 2025 15:05:22 +0530 Subject: [PATCH] Lower cluster size threshold on discover page --- .../apps/photos/lib/models/search/search_types.dart | 8 +++++++- mobile/apps/photos/lib/services/search_service.dart | 11 ++--------- .../photos/lib/ui/viewer/search/search_widget.dart | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mobile/apps/photos/lib/models/search/search_types.dart b/mobile/apps/photos/lib/models/search/search_types.dart index 7ee4961899..9ea97cbe82 100644 --- a/mobile/apps/photos/lib/models/search/search_types.dart +++ b/mobile/apps/photos/lib/models/search/search_types.dart @@ -14,6 +14,7 @@ import "package:photos/models/collection/collection_items.dart"; import "package:photos/models/search/search_result.dart"; import "package:photos/models/typedefs.dart"; import "package:photos/services/collections_service.dart"; +import "package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart"; import "package:photos/services/search_service.dart"; import "package:photos/ui/viewer/gallery/collection_page.dart"; import "package:photos/ui/viewer/location/add_location_sheet.dart"; @@ -220,7 +221,12 @@ extension SectionTypeExtensions on SectionType { }) { switch (this) { case SectionType.face: - return SearchService.instance.getAllFace(limit); + return SearchService.instance.getAllFace( + limit, + minClusterSize: limit == null + ? kMinimumClusterSizeAllFaces + : kMinimumClusterSizeSearchResult, + ); case SectionType.magic: return SearchService.instance.getMagicSectionResults(context!); case SectionType.location: diff --git a/mobile/apps/photos/lib/services/search_service.dart b/mobile/apps/photos/lib/services/search_service.dart index 735c2853d1..86a403694f 100644 --- a/mobile/apps/photos/lib/services/search_service.dart +++ b/mobile/apps/photos/lib/services/search_service.dart @@ -46,7 +46,6 @@ import 'package:photos/services/collections_service.dart'; import "package:photos/services/date_parse_service.dart"; import "package:photos/services/filter/db_filters.dart"; import "package:photos/services/location_service.dart"; -import "package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart"; import "package:photos/services/machine_learning/face_ml/person/person_service.dart"; import 'package:photos/services/machine_learning/semantic_search/semantic_search_service.dart'; import "package:photos/services/memories_cache_service.dart"; @@ -725,7 +724,7 @@ class SearchService { Future> getAllFace( int? limit, { - int minClusterSize = kMinimumClusterSizeSearchResult, + required int minClusterSize, }) async { try { debugPrint("getting faces"); @@ -894,13 +893,7 @@ class SearchService { ), ); } - if (facesResult.isEmpty) { - if (kMinimumClusterSizeAllFaces < minClusterSize) { - return getAllFace(limit, minClusterSize: kMinimumClusterSizeAllFaces); - } else { - return []; - } - } + if (facesResult.isEmpty) return []; if (limit != null) { return facesResult.sublist(0, min(limit, facesResult.length)); } else { diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart index 0bf9019d96..159b8ccf23 100644 --- a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart +++ b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart @@ -252,7 +252,7 @@ class SearchWidgetState extends State { }, ); - _searchService.getAllFace(null).then( + _searchService.getAllFace(null, minClusterSize: 10).then( (faceResult) { final List filteredResults = []; for (final result in faceResult) {