When training with the whole collection, include deleted card history
This commit is contained in:
parent
9a301665a4
commit
f8e0321ca5
@ -73,7 +73,7 @@ impl Collection {
|
|||||||
.search_cards_into_table(search, SortMode::NoOrder)?
|
.search_cards_into_table(search, SortMode::NoOrder)?
|
||||||
.col
|
.col
|
||||||
.storage
|
.storage
|
||||||
.get_revlog_entries_for_searched_cards_in_order()?;
|
.get_revlog_entries_for_searched_cards_in_card_order()?;
|
||||||
|
|
||||||
let first_rating_count = revlogs
|
let first_rating_count = revlogs
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -15,6 +15,8 @@ use itertools::Itertools;
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::revlog::RevlogEntry;
|
use crate::revlog::RevlogEntry;
|
||||||
use crate::revlog::RevlogReviewKind;
|
use crate::revlog::RevlogReviewKind;
|
||||||
|
use crate::search::Node;
|
||||||
|
use crate::search::SearchNode;
|
||||||
use crate::search::SortMode;
|
use crate::search::SortMode;
|
||||||
|
|
||||||
pub(crate) type Weights = Vec<f32>;
|
pub(crate) type Weights = Vec<f32>;
|
||||||
@ -57,10 +59,17 @@ impl Collection {
|
|||||||
&mut self,
|
&mut self,
|
||||||
search: impl TryIntoSearch,
|
search: impl TryIntoSearch,
|
||||||
) -> Result<Vec<RevlogEntry>> {
|
) -> Result<Vec<RevlogEntry>> {
|
||||||
|
let search = search.try_into_search()?;
|
||||||
|
// a whole-collection search can match revlog entries of deleted cards, too
|
||||||
|
if let Node::Group(nodes) = &search {
|
||||||
|
if let &[Node::Search(SearchNode::WholeCollection)] = &nodes[..] {
|
||||||
|
return self.storage.get_all_revlog_entries_in_card_order();
|
||||||
|
}
|
||||||
|
}
|
||||||
self.search_cards_into_table(search, SortMode::NoOrder)?
|
self.search_cards_into_table(search, SortMode::NoOrder)?
|
||||||
.col
|
.col
|
||||||
.storage
|
.storage
|
||||||
.get_revlog_entries_for_searched_cards_in_order()
|
.get_revlog_entries_for_searched_cards_in_card_order()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evaluate_weights(&mut self, weights: &Weights, search: &str) -> Result<ModelEvaluation> {
|
pub fn evaluate_weights(&mut self, weights: &Weights, search: &str) -> Result<ModelEvaluation> {
|
||||||
@ -70,7 +79,7 @@ impl Collection {
|
|||||||
let revlogs = guard
|
let revlogs = guard
|
||||||
.col
|
.col
|
||||||
.storage
|
.storage
|
||||||
.get_revlog_entries_for_searched_cards_in_order()?;
|
.get_revlog_entries_for_searched_cards_in_card_order()?;
|
||||||
anki_progress.state.fsrs_items = revlogs.len() as u32;
|
anki_progress.state.fsrs_items = revlogs.len() as u32;
|
||||||
let items = fsrs_items_for_training(revlogs, timing.next_day_at);
|
let items = fsrs_items_for_training(revlogs, timing.next_day_at);
|
||||||
let fsrs = FSRS::new(Some(weights))?;
|
let fsrs = FSRS::new(Some(weights))?;
|
||||||
|
@ -142,7 +142,7 @@ impl SqliteStorage {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_revlog_entries_for_searched_cards_in_order(
|
pub(crate) fn get_revlog_entries_for_searched_cards_in_card_order(
|
||||||
&self,
|
&self,
|
||||||
) -> Result<Vec<RevlogEntry>> {
|
) -> Result<Vec<RevlogEntry>> {
|
||||||
self.db
|
self.db
|
||||||
@ -154,6 +154,13 @@ impl SqliteStorage {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_all_revlog_entries_in_card_order(&self) -> Result<Vec<RevlogEntry>> {
|
||||||
|
self.db
|
||||||
|
.prepare_cached(concat!(include_str!("get.sql"), " order by cid, id"))?
|
||||||
|
.query_and_then([], row_to_revlog_entry)?
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_all_revlog_entries(&self, after: TimestampSecs) -> Result<Vec<RevlogEntry>> {
|
pub(crate) fn get_all_revlog_entries(&self, after: TimestampSecs) -> Result<Vec<RevlogEntry>> {
|
||||||
self.db
|
self.db
|
||||||
.prepare_cached(concat!(include_str!("get.sql"), " where id >= ?"))?
|
.prepare_cached(concat!(include_str!("get.sql"), " where id >= ?"))?
|
||||||
|
Loading…
Reference in New Issue
Block a user