feat(aisle): case-insensitive matching and preserve config order#88
Open
feat(aisle): case-insensitive matching and preserve config order#88
Conversation
- Make ingredient matching case-insensitive so "Chili flakes" matches "chili flakes" in aisle.conf (consistent with pantry behavior) - Preserve aisle.conf category order in shopping lists instead of sorting alphabetically - Add indexmap dependency for insertion-order preservation - Add tests for both behaviors
commit: |
Use --install-strategy=nested to avoid npm hoisting issues with platform-specific optional dependencies (rollup required by vitest). See: npm/cli#4828
Ingredients within each category now appear in the same order as they are listed in the aisle.conf file, not alphabetically. Changed IngredientList from BTreeMap to IndexMap and rewrote categorize() to iterate through aisle.conf ingredients in order.
2c2b5a3 to
95dcf15
Compare
Fixes mismatched_lifetime_syntaxes warnings by adding '_ to Cow return types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Details
Case-insensitive matching
Previously, aisle ingredient matching was case-sensitive, which caused issues when recipes used different casing than the aisle.conf file (e.g., "Chili flakes" vs "chili flakes"). This is now fixed by storing lowercase keys in the
ingredients_info()HashMap and using lowercase lookups.This brings aisle matching in line with pantry matching, which was already case-insensitive.
Preserve config order
Previously,
CategorizedIngredientListusedBTreeMapwhich sorted categories alphabetically. Users expected categories to appear in the same order as their aisle.conf file.This is fixed by:
indexmapdependency for insertion-order preservationcategorize()CategorizedIngredientList.categoriesfromBTreeMaptoIndexMapPreserve ingredient order within categories
Previously, ingredients within each category were sorted alphabetically. Now ingredients appear in the order they are listed in the aisle.conf file.
This is fixed by:
IngredientListfromBTreeMaptoIndexMapcategorize()to iterate through aisle.conf ingredients in orderTest plan
case_insensitive_lookuptest inaisle.rstest_categorize_preserves_aisle_ordertesttest_categorize_case_insensitivetesttest_use_common_names_case_insensitivetesttest_ingredients_preserve_aisle_order_within_categorytest