mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
tweak naming and move method into col.decks
This commit is contained in:
parent
c739b9782e
commit
e99a7c0f90
3 changed files with 12 additions and 13 deletions
|
@ -379,16 +379,6 @@ class Collection:
|
|||
def cardCount(self) -> Any:
|
||||
return self.db.scalar("select count() from cards")
|
||||
|
||||
def card_count_from_did(self, did: int, count_subdecks: bool = False) -> Any:
|
||||
dids: List[int] = [did]
|
||||
if count_subdecks:
|
||||
dids += [r[1] for r in self.decks.children(did)]
|
||||
count = self.db.scalar(
|
||||
"select count() from cards where did in {0} or "
|
||||
"odid in {0}".format(ids2str(dids))
|
||||
)
|
||||
return count
|
||||
|
||||
def remove_cards_and_orphaned_notes(self, card_ids: Sequence[int]):
|
||||
"You probably want .remove_notes_by_card() instead."
|
||||
self.backend.remove_cards(card_ids=card_ids)
|
||||
|
|
|
@ -210,6 +210,16 @@ class DeckManager:
|
|||
def count(self) -> int:
|
||||
return len(self.all_names_and_ids())
|
||||
|
||||
def card_count(self, did: int, include_subdecks: bool) -> Any:
|
||||
dids: List[int] = [did]
|
||||
if include_subdecks:
|
||||
dids += [r[1] for r in self.children(did)]
|
||||
count = self.col.db.scalar(
|
||||
"select count() from cards where did in {0} or "
|
||||
"odid in {0}".format(ids2str(dids))
|
||||
)
|
||||
return count
|
||||
|
||||
def get(self, did: Union[int, str], default: bool = True) -> Optional[Deck]:
|
||||
if not did:
|
||||
if default:
|
||||
|
|
|
@ -277,12 +277,11 @@ class DeckBrowser:
|
|||
def _delete(self, did: int):
|
||||
self.mw.checkpoint(tr(TR.DECKS_DELETE_DECK))
|
||||
deck = self.mw.col.decks.get(did)
|
||||
extra = None
|
||||
if not deck["dyn"]:
|
||||
count = self.mw.col.card_count_from_did(did, count_subdecks=True)
|
||||
count = self.mw.col.decks.card_count(did, include_subdecks=True)
|
||||
if count:
|
||||
extra = tr(TR.DECKS_IT_HAS_CARD, count=count)
|
||||
else:
|
||||
extra = None
|
||||
if (
|
||||
deck["dyn"]
|
||||
or not extra
|
||||
|
|
Loading…
Reference in a new issue