parent
e33a2bcb17
commit
c39f2cacae
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
7
rslib/src/storage/deck/active_deck_ids_sorted.sql
Normal file
7
rslib/src/storage/deck/active_deck_ids_sorted.sql
Normal file
@ -0,0 +1,7 @@
|
||||
SELECT id
|
||||
FROM decks
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM active_decks
|
||||
)
|
||||
ORDER BY name
|
@ -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<()> {
|
||||
|
Loading…
Reference in New Issue
Block a user