Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/export dataset for research #3511

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions rslib/src/scheduler/fsrs/weights.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing that Jarrett. Just one little tweak - please move this down

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use std::iter;
Expand All @@ -20,6 +21,7 @@ use fsrs::FSRS;
use itertools::Itertools;
use prost::Message;

use crate::decks::immediate_parent_name;
use crate::prelude::*;
use crate::revlog::RevlogEntry;
use crate::revlog::RevlogReviewKind;
Expand Down Expand Up @@ -138,18 +140,23 @@ impl Collection {
.map(revlog_entry_to_proto)
.collect_vec();
let cards = self.storage.get_all_card_entries()?;

let decks_map = self.storage.get_decks_map()?;
let deck_name_to_id: HashMap<String, DeckId> = decks_map
.into_iter()
.map(|(id, deck)| (deck.name.to_string(), id))
.collect();

let decks = self
.storage
.get_all_decks()?
.into_iter()
.filter_map(|deck| {
let parent_id = self
.storage
.parent_decks(&deck)
.ok()
.and_then(|parents| parents.first().map(|d| d.id.0))
.unwrap_or(0);
if let Some(preset_id) = deck.config_id().map(|id| id.0) {
let parent_id = immediate_parent_name(&deck.name.to_string())
.and_then(|parent_name| deck_name_to_id.get(parent_name))
.map(|id| id.0)
.unwrap_or(0);
Some(DeckEntry {
id: deck.id.0,
parent_id,
Expand Down