deck_tree() could be made to unbury the current day's cards
When provided with a future timestamp to estimate the next day's cards, it lead to the current day's buried cards being unburied. Fixes https://forums.ankiweb.net/t/inconsistent-card-counts-when-syncing/15496
This commit is contained in:
parent
9daa0c9acb
commit
d7f5555642
@ -285,13 +285,17 @@ impl From<DeckTreeNode> for LegacyDueCounts {
|
||||
|
||||
impl Collection {
|
||||
/// Get the deck tree.
|
||||
/// If now is provided, due counts for the provided timestamp will be populated.
|
||||
/// If top_deck_id is provided, only the node starting at the provided deck ID will
|
||||
/// have the counts populated. Currently the entire tree is returned in this case, but
|
||||
/// this may change in the future.
|
||||
/// - If `timestamp` is provided, due counts for the provided timestamp will
|
||||
/// be populated.
|
||||
/// - Buried cards from previous days will be unburied if necessary. Because
|
||||
/// this does not happen for future stamps, future due numbers may not be
|
||||
/// accurate.
|
||||
/// - If top_deck_id is provided, only the node starting at the provided
|
||||
/// deck ID will have the counts populated. Currently the entire tree is
|
||||
/// returned in this case, but this may change in the future.
|
||||
pub fn deck_tree(
|
||||
&mut self,
|
||||
now: Option<TimestampSecs>,
|
||||
timestamp: Option<TimestampSecs>,
|
||||
top_deck_id: Option<DeckId>,
|
||||
) -> Result<DeckTreeNode> {
|
||||
let names = self.storage.get_all_deck_names()?;
|
||||
@ -299,18 +303,22 @@ impl Collection {
|
||||
|
||||
let decks_map = self.storage.get_decks_map()?;
|
||||
|
||||
add_collapsed_and_filtered(&mut tree, &decks_map, now.is_none());
|
||||
add_collapsed_and_filtered(&mut tree, &decks_map, timestamp.is_none());
|
||||
if self.default_deck_is_empty()? {
|
||||
hide_default_deck(&mut tree);
|
||||
}
|
||||
|
||||
if let Some(now) = now {
|
||||
if let Some(timestamp) = timestamp {
|
||||
// cards buried on previous days need to be unburied for the current
|
||||
// day's counts to be accurate
|
||||
let timing_today = self.timing_today()?;
|
||||
self.unbury_if_day_rolled_over(timing_today)?;
|
||||
|
||||
let limit = top_deck_id
|
||||
.and_then(|did| decks_map.get(&did).map(|deck| deck.name.as_native_str()));
|
||||
let timing = self.timing_for_timestamp(now)?;
|
||||
self.unbury_if_day_rolled_over(timing)?;
|
||||
let days_elapsed = timing.days_elapsed;
|
||||
let learn_cutoff = (now.0 as u32) + self.learn_ahead_secs();
|
||||
let timing_at_stamp = self.timing_for_timestamp(timestamp)?;
|
||||
let days_elapsed = timing_at_stamp.days_elapsed;
|
||||
let learn_cutoff = (timestamp.0 as u32) + self.learn_ahead_secs();
|
||||
let sched_ver = self.scheduler_version();
|
||||
let v3 = self.get_config_bool(BoolKey::Sched2021);
|
||||
let counts = self.due_counts(days_elapsed, learn_cutoff, limit)?;
|
||||
|
Loading…
Reference in New Issue
Block a user