lune-stone / anki-addon-limit-new-by-young

An add-on for Anki that can aid in maintaining a stable and efficient daily workload.
GNU Affero General Public License v3.0
4 stars 2 forks source link

Add number of cards introduced today & Exclude suspended cards #7

Closed user1823 closed 8 months ago

user1823 commented 8 months ago

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.

lune-stone commented 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
user1823 commented 8 months ago

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.

lune-stone commented 8 months ago

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.

user1823 commented 8 months ago

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.