-
-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] - Cookbook using a Tag filter doesn't find all recipes with that tag #4789
Comments
+1 |
I wonder how this could be replicated. I have 12 recipes tagged with "Want to Make" and a Cookbook that shows all of those successfully. The inclusion rule is very simple so if not everything is being displayed, something must be going on. For the ones that don't show up, what if you REMOVE, save, ADD the tag back? |
in my case the recipies page with category filter looks correct (4 recepies) but the cookbok page looks like this, empty, Now, that is a fairly new Category (Smoothies), and i have older categories with 50+ recepies and i have noticed that older recepies shows up correctly in cookbooks, but newer ones rarely (if any?) shows up on in the Cookbooks. So this is most likely a newer issue that is dependent on version when recipe was created. |
Would be happy to add a test user, backup and publish database if it helps. |
Extra data point: I just did the test with Categories, and did NOT see the same behavior that I'm seeing with Tags. Specifically, I currently have 165 recipes with category "Cocktail", and 3 with category "Cocktail Mixers". A cookbook with category "One of 'Cocktails'" shows all 165 recipes. "All of 'Cocktails'" shows 165. And "One of 'Cocktails' or 'Cocktail Mixers'" shows 168, as expected. One observation is that all of my recipes have exactly 1 category, but one-to-many tags. For folks who are seeing this issue with categories, do you have multiple categories assigned to recipes? |
Most of mine have 1 category (i dont use tags), however, one of my categories have two recipies that has multiple categories. in the Recipe page with filter they both show up (again both these has multiple categories) on the Cookbook page, only one of them are shown, but like i said, most only have 1 categories and some show and some dont, seem more related to recipe age in my case. |
Interesting. I went to see whether my missing Tiki cocktails were the oldest ones -- I didn't remember seeing a correlation like that -- and the Tiki cookbook is working now, and showing all of the expected recipes. I literally did not change anything with that cookbook, although I was experimenting with different cookbooks a few minutes ago as described above. |
Noticed that if you sort by Rating, all recipies that dont have a rating is hidden. |
For everyone running into issues, can you please post a screenshot of your cookbook settings (like above) as well as the response from the API when fetching said cookbook? For example: {
"name": "Family Cookbook 1",
"description": "",
"slug": "family-cookbook-1",
"position": 1,
"public": false,
"queryFilterString": "recipe_category.id IN [\"f81c88d1-5b3d-4cd7-80b3-d2b23da41af4\"]",
"groupId": "7b3fc078-c988-413f-b8a2-a8c0a6e03e34",
"householdId": "a374edd1-3b53-4b71-897e-f8198d7333b0",
"id": "c3098bd4-ad40-4062-b8c7-b1ebe8bed7a3",
"queryFilter": {
"parts": [
{
"leftParenthesis": null,
"rightParenthesis": null,
"logicalOperator": null,
"attributeName": "recipe_category.id",
"relationalOperator": "IN",
"value": [
"f81c88d1-5b3d-4cd7-80b3-d2b23da41af4"
]
}
]
},
"recipes": [...]
} This data, along with a description of what you expect to see vs what you're actually seeing. I haven't been able to reproduce any issues locally, so I need more data to debug |
@michael-genson Not sure how to see/test the API result - Quick question, are you able to reproduce the issue where a recipe is not This might have been the culprit for me all along. |
Can confirm, for me, I have all my recipes disappear if I sort by rating My tag is 'Want to Cook' and I've not rated anything so that tracks. So it's not necessarily an API issue, more a filtering issue that the 'Rating' button doesnt show a '0' / 'unrated' rating? |
To see the network request, you can open the console on your browser (usually F12). It also helps to turn on the XHR filter (which will only show you the server requests) Regarding the ratings, I'm not at my computer right now, but that sounds like a similar issue we ran into when we first implemented the last made sort |
The same issue applies to 'recipes' then. If you filter with a Category / Tag and then 'SORT BY' Rating, anything that isnt rated disappears. |
When I was seeing this issue, I was not changing any of the sorting settings in the cookbook config. Almost none of my recipes have ratings. |
Yes, however the sorting is shared between all Cookbooks but seperate for Recipe page. So i can have the Recipe page sorted by Date and Cookbooks sorted by Rating, thats probably why i first thought it was only occuring on the Cookbooks but you are correct that it applies to all pages as soon as a sort for rating is applied. |
Here's mine. {
} |
Noticed something in the request url/xhr/fetch when setting the Rating as sorting it also adds a queryFilter to not include NULL ratings - changing Sort order it removes this. |
@PancakeZik what value are you sorting by? And, can you try changing the sort and seeing if that fixes the issue? I have a feeling this is related to nulls and the following relationships:
Try to see if which recipes are missing are correlated to those properties (e.g. they all do/don't have ratings, are/aren't favorited, etc.) The reason I suspect this is because the query we're building does some joins on those relationships |
I can confirm that setting it to sort by Ratings or Last Made will 'break' it from Favorites, Recipes, and Cookbooks. Sorting by Alphabetical or something that will always have a 'value' or sorts will bring it back. But that definitely does add to confusion - If I sort by rating, it should be from 0 - 5, not 1 - 5. Last made should also include NULL from 'Not Made > Most Recently Made' |
Interesting, I investigated and in my case I don't think it's related to sorting. |
Hmmmm, that might have something to do with pagination then. Our page size is 30 |
I can confirm sorting by last made or rating is broken; that is definitely missing unmade/unrated recipes. Try as I might I can't reproduce the tag/category issue. I've tried a bunch of different tag/category combinations with different sorts and it always matches exactly what I expect (the only exceptions being mentioned above) |
Not used to python but i see some suspicious code in the repo, `class RepositoryRecipes(HouseholdRepositoryGeneric[Recipe, RecipeModel]):
` ` def _get_rating_col_alias(self) -> sa.ColumnElement | None:
|
Yeah those generate subqueries to calculate the sort values. My gut says we're probably doing an inner join instead of an outer join. Need to dig in further though and probably look at the generated SQL |
What file is 'sort' code under? I'd like to take a look myself, just out of curiosity. I'm more familiar with MS SQL, but im sure that can translate back to SQLite and Postgres, at least to look through a bit. |
Turns out it was the frontend adding a "IS NOT NULL" constraint before sending to the backend. This comes from some old code that probably made sense at the time, but doesn't make sense now. More here: #4908 |
Ah good find, wondered why the fetch was adding that to the url request. |
First Check
What is the issue you are experiencing?
I have a couple hundred recipes in Mealie, including many cocktails. 34 of the the cocktails have the tag "Tiki" amongst other tags. I created a cookbook called "Tiki Cocktails" which should pull recipes that have "contains all of" the single tag "Tiki". Only 22 recipes get pulled into the cookbook.
I created a second cookbook called Tiki 2 using the same filter criteria, and it ends up containing the same 22 recipes. I also attempted this using an "is one of" filter, and get the same results.
If I look at the main recipes page, and filter using tag "Tiki", all 34 recipes get displayed.
I was not able to replicate this behavior on the demo site, but my test recipes there are obviously much simpler and don't have multiple Tags amongst other confounding factors.
Steps to Reproduce
Create a new cookbook. Select filter criteria for Tag called "Tiki". Save the cookbook. View the cookbook. Observe that only a subset of expected recipes are included.
Please provide relevant logs
Docker log contains no error messages, just access logs. Relevant request looks like:
INFO 2024-12-29T12:42:24 - [10.111.1.5:54334] 200 OK "GET /api/recipes?page=1&perPage=64&orderBy=name&orderDirection=asc&cookbook=tiki-cocktails HTTP/1.1"
Mealie Version
Docker image: ghcr.io/mealie-recipes/mealie:nightly
Build: 23a85f51d20b12ee93f7b25d312d70d18be0e92d
Deployment
Unraid
Additional Deployment Details
No response
The text was updated successfully, but these errors were encountered: