Closed user1823 closed 8 months ago
Hmm, this looks like it can cause you to go over the youngCardLimit
under some circumstances.
For example:
--- before study ---
maxNewCardsPerDay = ∞
youngCardLimit = 50
youngCount = 40
introduced_today = 0
matured_today = 0
newLimit = max(0, min(maxNewCardsPerDay - introduced_today, youngCardLimit - youngCount)) + introduced_today
= max(0, min(∞ - 0, 50 - 40)) + 0
= 10
--- after study + recalculation ---
introduced_today = 10
matured_today = 3
maxNewCardsPerDay = ∞
youngCardLimit = 50
youngCount = before.youngCardLimit + introduced_today - matured_today
= 40 + 10 - 3
= 47
preChange.newLimit = max(0, min(maxNewCardsPerDay, youngCardLimit - youngCount))
= max(0, min(∞, 50 - 47))
= 3
postChange.newLimit = max(0, min(maxNewCardsPerDay - introduced_today, youngCardLimit - youngCount)) + introduced_today
= max(0, min(∞ - 10, 50 - 47)) + 10
= 13
--- final totals ---
youngCardLimit = 50
preChange.youngCount = 50
postChange.youngCount = 60
postChange.youngCount = 60
I don't think that this is correct. After setting the limit to 13, the user will only get 3 additional cards because he has already done 10 new cards on that day.
You are correct, I was forgetting that Anki counts introduced against today's limit.
I've tested the change by creating a test deck an manually setting the review date forward >21 (which doesn't actually update the true young count according to stats as the interval remains unchanged, but does cause the add-on to classify it as not young, which is probably a bug). With your change the recalculated limit is updated correctly.
but does cause the add-on to classify it as not young, which is probably a bug
It happens because you have prop:due<21
in the search query.
Let's say that my new card limit is set to 50 cards. I do some cards, including 30 new cards. Then, I recalculate my new card limit using the add-on. Now, the add-on calculates that I can do 15 more new cards. But if it sets the limit to 15, Anki won't show me any new cards. To get 15 more cards, the limit should be set to 30 + 15 = 45.
I haven't tested this. So, please test it before merging.