Add some utility functions for use by new "Interleaved Decks" gather priority.

This commit is contained in:
David Grundberg 2026-01-09 20:42:56 +01:00
parent 57e47a5f09
commit 666ac11e2c
2 changed files with 19 additions and 1 deletions

View file

@ -351,7 +351,7 @@ impl LimitTreeMap {
.map(|node_id| self.get_node_limits(node_id)) .map(|node_id| self.get_node_limits(node_id))
} }
fn get_root_limits(&self) -> RemainingLimits { pub(crate) fn get_root_limits(&self) -> RemainingLimits {
self.get_node_limits(self.tree.root_node_id().unwrap()) self.get_node_limits(self.tree.root_node_id().unwrap())
} }

View file

@ -341,6 +341,24 @@ impl super::SqliteStorage {
Ok(()) Ok(())
} }
pub(crate) fn new_cards_in_deck(
&self,
deck: DeckId,
sort: NewCardSorting,
) -> Result<Vec<NewCard>> {
let mut stmt = self.db.prepare_cached(&format!(
"{} ORDER BY {}",
include_str!("new_cards.sql"),
sort.write()
))?;
let mut rows = stmt.query(params![deck])?;
let mut names = Vec::new();
while let Some(row) = rows.next()? {
names.push(row_to_new_card(row)?);
}
Ok(names)
}
/// Call func() for each new card in the active decks, stopping when it /// Call func() for each new card in the active decks, stopping when it
/// returns false or no more cards found. /// returns false or no more cards found.
pub(crate) fn for_each_new_card_in_active_decks<F>( pub(crate) fn for_each_new_card_in_active_decks<F>(