Closed ohamz closed 5 months ago
The only files that I modified are:
RecipeRepository
SearchViewModel.kt
SearchViewModelTest.kt
All the rest was 'modified' due to rebasing and resolving conflicts with main.
For the search logic change I think it is a shame that we don't support partial word queries, as with only a certain substring (e.g "del") displaying all recipes which titles contain that substring.
It's easier said than done ... I did some research and this implementation was the best solution between effectiveness and efficiency. Searching for a substring will require us to fetch ALL the recipes from the database and compare them one by one with the query.
The recipe is displayed twice, and there is a non-functional load more button when testing on emulator
The recipe is displayed twice because there are duplicate recipes in the database. As for the load button, it isn't working because there are no more recipes to fetch (maybe a future PR would be to remove this button when it's the case). If you try with "chicken" you can try and see if the button works.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
76.3% Coverage on New Code
0.0% Duplication on New Code
For the search logic change I think it is a shame that we don't support partial word queries, as with only a certain substring (e.g "del") displaying all recipes which titles contain that substring.
It's easier said than done ... I did some research and this implementation was the best solution between effectiveness and efficiency. Searching for a substring will require us to fetch ALL the recipes from the database and compare them one by one with the query.
Okay, smart move then to avoid wasting our precious API calls x)
The recipe is displayed twice, and there is a non-functional load more button when testing on emulator
The recipe is displayed twice because there are duplicate recipes in the database. As for the load button, it isn't working because there are no more recipes to fetch (maybe a future PR would be to remove this button when it's the case). If you try with "chicken" you can try and see if the button works.
Okay it makes a lot more sense, and it would be great to hide the button if there is no more recipes to fetch for sure
Upon searching a recipe, the app crash when the recipe is clicked on (Actually this problem arises when clicking on any of the database recipes, for example lasagna1 and pasta1 work). And also the searching logic has to be modified.
Update:
So I modified the search bar logic, instead of searching for an exact prefix of the title of a recipe, now you can search the words of the title.
For example if I have a recipe with title "Delicious Apple Pie":
I did this by adding a new field to the recipes,
searchItems
, that contains the words of the title in an array of lowercase strings (["delicious", "apple", "pie"] for the example above), and before I compare the input query to check if it's withing this list, I convert it to lower case.