I want to add a new line to show the sum of due and new cards across all decks; I can get the number of due cards with len(mw.col.find_cards("is:due"))
but how can I find the number of scheduled new cards as shown in the New
column? mw.col.find_cards("is:new")
gives all new cards, not just scheduled, i.e sum of the boxed numbers:
Thanks!
example snippet:
from aqt import mw
from aqt.qt import *
from aqt.gui_hooks import deck_browser_will_render_content
def add_(overview, content):
ids = len(mw.col.find_cards("is:due"))
content.stats = f"""\n<div> Due: <font color="#00d100"> {ids} </font> </div>\n<br>""" + content.stats
deck_browser_will_render_content.append(add_)
abdo
July 20, 2021, 3:19am
2
Try mw.col.sched.deck_due_tree()
, which is what Anki uses to populate the deck list counts :
def new_count():
top = mw.col.sched.deck_due_tree()
count = 0
for child in top.children:
count += child.new_count
return count
2 Likes
Thanks!
code snippet if anyone’s interested
from aqt import mw
# from aqt.qt import *
from aqt.gui_hooks import deck_browser_will_render_content, profile_did_open
def clr_str(s,c):
return f"""<font color="#{c}"> {str(s)} </font>"""
def new_count():
top = mw.col.sched.deck_due_tree()
count = 0
for child in top.children:
count += child.new_count
return count
def add_info(overview, content):
n_due = len(mw.col.find_cards("is:due"))
n_new = new_count()
due_str = clr_str(n_due,"00d100")
new_str = clr_str(n_new,"4bc2ff")
n_tot = n_due + n_new
content.stats = f"\n<div> Σ {due_str} due + {new_str} new = {n_tot} </div>\n<br>" + content.stats
def add_deckbrowser_hook():
deck_browser_will_render_content.append(add_info)
profile_did_open.append(add_deckbrowser_hook)
1 Like
dae
July 21, 2021, 9:31am
4
Another option is to nest all of your decks under a single parent deck, which will give you separate due and new totals for all the decks.