Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Jun 14, 2024
1 parent a79ced4 commit a1dc5c3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions schedule/reschedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class FSRS:
p_obey_easy_days: float
easy_specific_due_dates: List[int]
p_obey_specific_due_dates: float
due_cnt_perday_from_first_day: Dict[int, int]
backlog: int
learned_cnt_today: int
due_cnt_per_day: Dict[int, int]
due_today: int
reviewed_today: int
card: Card
elapsed_days: int
allow_to_past: bool
Expand All @@ -44,7 +44,7 @@ def __init__(self) -> None:
def set_load_balance(self, did_query=None):
self.enable_load_balance = True
true_due = "CASE WHEN odid==0 THEN due ELSE odue END"
self.due_cnt_perday_from_first_day = defaultdict(
self.due_cnt_per_day = defaultdict(
int,
{
day: cnt
Expand All @@ -58,12 +58,12 @@ def set_load_balance(self, did_query=None):
)
},
)
self.backlog = sum(
self.due_today = sum(
due_cnt
for due, due_cnt in self.due_cnt_perday_from_first_day.items()
for due, due_cnt in self.due_cnt_per_day.items()
if due <= mw.col.sched.today
)
self.learned_cnt_today = mw.col.db.scalar(
self.reviewed_today = mw.col.db.scalar(
f"""SELECT count(distinct cid)
FROM revlog
WHERE ease > 0
Expand Down Expand Up @@ -132,10 +132,10 @@ def apply_fuzz(self, ivl):

if check_due > mw.col.sched.today:
# If the due date is in the future, the workload is the number of cards due on that day
workload = self.due_cnt_perday_from_first_day[check_due]
workload = self.due_cnt_per_day[check_due]
else:
# If the due date is in the past or today, the workload is the number of cards due today plus the number of cards learned today
workload = self.backlog + self.learned_cnt_today
workload = self.due_today + self.reviewed_today
if workload < min_workload:
best_ivl = check_ivl
min_workload = workload
Expand Down Expand Up @@ -347,12 +347,12 @@ def reschedule_card(cid, fsrs: FSRS, recompute=False):
card = update_card_due_ivl(card, new_ivl)
due_after = card.odue if card.odid else card.due
if fsrs.enable_load_balance:
fsrs.due_cnt_perday_from_first_day[due_before] -= 1
fsrs.due_cnt_perday_from_first_day[due_after] += 1
fsrs.due_cnt_per_day[due_before] -= 1
fsrs.due_cnt_per_day[due_after] += 1
if due_before <= mw.col.sched.today and due_after > mw.col.sched.today:
fsrs.backlog -= 1
fsrs.due_today -= 1
if due_before > mw.col.sched.today and due_after <= mw.col.sched.today:
fsrs.backlog += 1
fsrs.due_today += 1
return card


Expand Down

0 comments on commit a1dc5c3

Please sign in to comment.