Skip to content

Commit

Permalink
Actually fix STadas#20
Browse files Browse the repository at this point in the history
  • Loading branch information
STadas committed May 3, 2022
1 parent 50bf327 commit 2536557
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,29 +156,29 @@ def __update_rpc_next_state(self) -> None:
return

due_count = 0
node = collection.sched.deck_due_tree()
count_deck = self.__cfg_val(self.main_cfg, 'count_deck', bool)

if count_deck and self.last_deck is not None:
try:
last_id = int(self.last_deck['id'])
node = next(d for d in node.children if d.deck_id == last_id)
except StopIteration as ex:
print("Couldn't find deck:", ex)
node = collection.sched.deck_due_tree(self.last_deck['id'])
else:
node = collection.sched.deck_due_tree()

try:
if count_deck and self.last_deck is not None:
if node and node.children:
counts = {
"new": sum(ch.new_count for ch in node.children),
"learn": sum(ch.learn_count for ch in node.children),
"review": sum(ch.review_count for ch in node.children),
}
elif node:
counts = {
"new": node.new_count,
"learn": node.learn_count,
"review": node.review_count,
}
else:
counts = {
"new": sum(ch.new_count for ch in node.children),
"learn": sum(ch.learn_count for ch in node.children),
"review": sum(ch.review_count for ch in node.children),
}
counts = {}

counts_keys = self.__cfg_val(self.main_cfg, 'counts', list)
if isinstance(counts_keys, list):
for key in counts_keys:
Expand Down

0 comments on commit 2536557

Please sign in to comment.