export revlogs where the rating is between 1 and 4 for research (#3524)

This commit is contained in:
Jarrett Ye 2024-10-26 17:38:17 +08:00 committed by GitHub
parent 5caeac530e
commit 9a44881121
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -129,7 +129,7 @@ impl Collection {
/// Used for exporting revlogs for algorithm research.
pub fn export_dataset(&mut self, min_entries: usize, target_path: &Path) -> Result<()> {
let revlog_entries = self.storage.get_all_revlog_entries_in_card_order()?;
let revlog_entries = self.storage.get_revlog_entries_for_export_dataset()?;
if revlog_entries.len() < min_entries {
return Err(AnkiError::FsrsInsufficientData);
}

View file

@ -154,6 +154,17 @@ impl SqliteStorage {
.collect()
}
pub(crate) fn get_revlog_entries_for_export_dataset(&self) -> Result<Vec<RevlogEntry>> {
self.db
.prepare_cached(concat!(
include_str!("get.sql"),
" where ease between 1 and 4",
" order by cid, id"
))?
.query_and_then([], row_to_revlog_entry)?
.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"))?