Skip to content

Commit

Permalink
respect easy days
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Aug 5, 2024
1 parent e62026c commit 2ca8229
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions schedule/flatten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict
from ..configuration import Config
from ..utils import *
from anki.decks import DeckManager
from anki.utils import ids2str
Expand Down Expand Up @@ -46,11 +47,19 @@ def on_done(future):


def flatten_background(did, desired_flatten_limit):
config = Config()
config.load()

easy_days = []
if config.load_balance:
easy_days = config.easy_days

DM = DeckManager(mw.col)
if did is not None:
did_list = ids2str(DM.deck_and_child_ids(did))

today = mw.col.sched.today
current_date = sched_current_date()
true_due = "CASE WHEN odid==0 THEN due ELSE odue END"

cards_exceed_future = mw.col.db.all(
Expand Down Expand Up @@ -143,6 +152,9 @@ def flatten_background(did, desired_flatten_limit):
rest_cnt = len(cards_to_flatten) - cnt
if rest_cnt <= 0:
break
due_date = current_date + timedelta(days=new_due - today)
if config.load_balance and due_date.weekday() in easy_days:
continue
due_cnt = due_cnt_per_day[new_due]
if due_cnt > desired_flatten_limit:
continue
Expand Down

0 comments on commit 2ca8229

Please sign in to comment.