From 27e829380cf49f7ab26d08cf7de1060df251c053 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:36:25 -0500 Subject: [PATCH] group uncategorized constructs in with constructs with matching typing and lemma (#1063) --- .../analytics/construct_list_model.dart | 33 +++++++++++++++++-- .../practice_activity_model.dart | 2 ++ .../learning_progress_indicators.dart | 2 -- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/pangea/models/analytics/construct_list_model.dart b/lib/pangea/models/analytics/construct_list_model.dart index bcf676db3..93277b7be 100644 --- a/lib/pangea/models/analytics/construct_list_model.dart +++ b/lib/pangea/models/analytics/construct_list_model.dart @@ -86,10 +86,39 @@ class ConstructListModel { void _updateCategoriesToUses() { _categoriesToUses = {}; + + final Map> groupedMap = {}; for (final use in constructList()) { - _categoriesToUses[use.category] ??= []; - _categoriesToUses[use.category]!.add(use); + // Step 1: Create a key based on type, lemma, and category + String key = use.id.string; + + // If category is "other", find a more specific group if it exists + if (use.category.toLowerCase() == 'other') { + final String specificKeyPrefix = use.id.partialKey; + final String existingSpecificKey = groupedMap.keys.firstWhere( + (k) => k.startsWith(specificKeyPrefix) && !k.endsWith('other'), + orElse: () => '', + ); + + if (existingSpecificKey.isNotEmpty) { + key = existingSpecificKey; + } + } + + // Add the object to the grouped map + groupedMap.putIfAbsent(key, () => []).add(use); } + + // Step 2: Reorganize by category only + final Map> groupedByCategory = {}; + for (final entry in groupedMap.entries) { + // Extract the category part from the key (assuming it's at the end) + final category = entry.key.split('-').last; + + // Add each item in this entry to the groupedByCategory map under the single category key + groupedByCategory.putIfAbsent(category, () => []).addAll(entry.value); + } + _categoriesToUses = groupedByCategory; } void _updateMetrics() { diff --git a/lib/pangea/models/practice_activities.dart/practice_activity_model.dart b/lib/pangea/models/practice_activities.dart/practice_activity_model.dart index d871e0836..13e55ae46 100644 --- a/lib/pangea/models/practice_activities.dart/practice_activity_model.dart +++ b/lib/pangea/models/practice_activities.dart/practice_activity_model.dart @@ -74,6 +74,8 @@ class ConstructIdentifier { String get string => "$lemma-${type.string}${category != "" ? "-$category" : "-other"}"; + + String get partialKey => "$lemma-${type.string}"; } class CandidateMessage { diff --git a/lib/pangea/widgets/chat_list/analytics_summary/learning_progress_indicators.dart b/lib/pangea/widgets/chat_list/analytics_summary/learning_progress_indicators.dart index d737cc4f5..42132f169 100644 --- a/lib/pangea/widgets/chat_list/analytics_summary/learning_progress_indicators.dart +++ b/lib/pangea/widgets/chat_list/analytics_summary/learning_progress_indicators.dart @@ -119,8 +119,6 @@ class LearningProgressIndicatorsState context: context, builder: (c) => AnalyticsPopup( type: indicator.constructType, - showGroups: indicator == - ProgressIndicatorEnum.morphsUsed, ), ); },