Skip to content

Commit

Permalink
Feat/skip manually scheduled cards when rescheduling (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
user1823 authored Dec 1, 2024
1 parent cc3cabe commit 805d290
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 49 deletions.
27 changes: 0 additions & 27 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,6 @@ def set_auto_disperse_after_reschedule(checked, _):
)


def set_skip_manual_resched_cards(checked, _):
if config.skip_manual_resched_cards:
config.skip_manual_resched_cards = checked
else:
warning = (
"Due to the nature of Anki's database, FSRS Helper cannot distinguish among cards rescheduled by following operations:\n"
+ "- Set due date\n"
+ "- Reset (earlier called Forget)\n"
+ "- 'Reschedule cards on change' in FSRS section of Deck Options\n\n"
+ "When you enable this option, cards that were last modified by any of the above will be skipped during rescheduling."
)
checked = askUser(
warning,
title="Warning",
)
config.skip_manual_resched_cards = checked
menu_skip_manual_resched_cards.setChecked(checked)


menu_skip_manual_resched_cards = checkable(
title="Skip manually rescheduled cards when rescheduling",
on_click=set_skip_manual_resched_cards,
)


def set_display_memory_state(checked, _):
config.display_memory_state = checked

Expand Down Expand Up @@ -278,7 +253,6 @@ def search_stats_extended(did=None):
menu_for_easy_days = menu_for_helper.addMenu(
"Less Anki on Easy Days (requires Load Balancing)"
)
menu_for_helper.addAction(menu_skip_manual_resched_cards)
menu_for_helper.addSeparator()
menu_for_helper.addAction(menu_reschedule)
menu_for_helper.addAction(menu_reschedule_recent)
Expand Down Expand Up @@ -345,7 +319,6 @@ def adjust_menu():
menu_auto_disperse_after_reschedule.setChecked(
config.auto_disperse_after_reschedule
)
menu_skip_manual_resched_cards.setChecked(config.skip_manual_resched_cards)
menu_for_auto_easy_days.setChecked(config.auto_easy_days)


Expand Down
1 change: 0 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
"auto_easy_days": false,
"has_rated": false,
"has_sponsored": false,
"skip_manual_resched_cards": false,
"show_steps_stats": false
}
10 changes: 0 additions & 10 deletions configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
AUTO_EASY_DAYS = "auto_easy_days"
HAS_RATED = "has_rated"
HAS_SPONSORED = "has_sponsored"
SKIP_MANUAL_RESCHED_CARDS = "skip_manual_resched_cards"
SHOW_STEPS_STATS = "show_steps_stats"


Expand Down Expand Up @@ -185,15 +184,6 @@ def has_sponsored(self, value):
self.data[HAS_SPONSORED] = value
self.save()

@property
def skip_manual_resched_cards(self):
return self.data[SKIP_MANUAL_RESCHED_CARDS]

@skip_manual_resched_cards.setter
def skip_manual_resched_cards(self, value):
self.data[SKIP_MANUAL_RESCHED_CARDS] = value
self.save()

@property
def show_steps_stats(self):
return self.data[SHOW_STEPS_STATS]
Expand Down
17 changes: 6 additions & 11 deletions schedule/reschedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,6 @@ def reschedule_background(
if filter_flag:
filter_query = f"AND id IN {ids2str(filtered_cids)}"

if config.skip_manual_resched_cards:
skip_query = """
AND id NOT IN (
SELECT cid
FROM revlog
GROUP BY cid
HAVING MAX(CASE WHEN ease = 0 THEN id ELSE NULL END) = MAX(id)
)
"""

cid_did_nid = mw.col.db.all(
f"""
SELECT
Expand All @@ -331,7 +321,12 @@ def reschedule_background(
{did_query if did_query is not None else ""}
{recent_query if recent else ""}
{filter_query if filter_flag else ""}
{skip_query if config.skip_manual_resched_cards else ""}
AND id NOT IN (
SELECT cid
FROM revlog
GROUP BY cid
HAVING MAX(CASE WHEN type = 4 THEN id ELSE NULL END) = MAX(id)
)
ORDER BY ivl
"""
)
Expand Down

0 comments on commit 805d290

Please sign in to comment.