feat(aisle): case-insensitive matching and preserve config order #88
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