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

Round new_limit persisted output #27

Closed Swiddis closed 2 months ago

Swiddis commented 2 months ago

While using the young card limit of 375.0 with a deck that had 361 young cards and 20 new cards per day, I noticed the plugin wasn't throttling gradually. Figuring it may only throttling after the limit is passed, I tried 360.0 and noticed it immediately went to 0. Trying to get gradual behavior I did some digging around the plugin.

It turns out, since the config value was a float, the computed new_limit came out to 14.0. The problem is that when persisting this new limit with deck["newLimitToday"] = { "limit": new_limit, ... }, Anki silently ignores floating-point values of the limit, so this ends up being equivalent to no limit being applied.

This commit rounds the limit to an integer before storage, to ensure it's persisted regardless of any other floating-point weirdness. As a workaround, one should ensure their config only uses integer limits, at least for the young and soon limits since the load limit is math.ceiled before storage.

lune-stone commented 2 months ago

Testing on my end looks good. I've tagged the latest master and updated the artifact on ankiweb. Thanks for the good work!