Fix new cards from parent decks being gathered (#2907)

Fixes #2906.
This commit is contained in:
RumovZ 2023-12-24 11:04:28 +01:00 committed by GitHub
parent e33a2bcb17
commit c39f2cacae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 11 deletions

View File

@ -190,7 +190,6 @@ pub(crate) fn remaining_limits_map<'a>(
/// Wrapper of [RemainingLimits] with some additional meta data.
#[derive(Debug, Clone, Copy)]
struct NodeLimits {
deck_id: DeckId,
/// absolute level in the deck hierarchy
level: usize,
limits: RemainingLimits,
@ -204,7 +203,6 @@ impl NodeLimits {
new_cards_ignore_review_limit: bool,
) -> Self {
Self {
deck_id: deck.id,
level: deck.name.components().count(),
limits: RemainingLimits::new(
deck,
@ -365,14 +363,6 @@ impl LimitTreeMap {
Ok(self.get_deck_limits(deck_id)?.get(kind) == 0)
}
pub(crate) fn active_decks(&self) -> Vec<DeckId> {
self.tree
.traverse_pre_order(self.tree.root_node_id().unwrap())
.unwrap()
.map(|node| node.data().deck_id)
.collect()
}
pub(crate) fn decrement_deck_and_parent_limits(
&mut self,
deck_id: DeckId,

View File

@ -91,7 +91,7 @@ impl QueueBuilder {
col: &mut Collection,
sort: NewCardSorting,
) -> Result<()> {
for deck_id in self.limits.active_decks() {
for deck_id in col.storage.get_active_deck_ids_sorted()? {
if self.limits.root_limit_reached(LimitKind::New) {
break;
}

View File

@ -0,0 +1,7 @@
SELECT id
FROM decks
WHERE id IN (
SELECT id
FROM active_decks
)
ORDER BY name

View File

@ -359,6 +359,13 @@ impl SqliteStorage {
Ok(())
}
pub(crate) fn get_active_deck_ids_sorted(&self) -> Result<Vec<DeckId>> {
self.db
.prepare_cached(include_str!("active_deck_ids_sorted.sql"))?
.query_and_then([], |row| row.get(0).map_err(Into::into))?
.collect()
}
// Upgrading/downgrading/legacy
pub(super) fn add_default_deck(&self, tr: &I18n) -> Result<()> {