diff --git a/proto/backend.proto b/proto/backend.proto index cb5f4bccc..ac5340e32 100644 --- a/proto/backend.proto +++ b/proto/backend.proto @@ -408,7 +408,7 @@ message CardTemplate { message Note { int64 id = 1; string guid = 2; - int64 ntid = 3; + int64 notetype_id = 3; uint32 mtime_secs = 4; int32 usn = 5; repeated string tags = 6; @@ -417,21 +417,21 @@ message Note { message Card { int64 id = 1; - int64 nid = 2; - int64 did = 3; - uint32 ord = 4; - int64 mtime = 5; + int64 note_id = 2; + int64 deck_id = 3; + uint32 template_idx = 4; + int64 mtime_secs = 5; sint32 usn = 6; uint32 ctype = 7; sint32 queue = 8; sint32 due = 9; - uint32 ivl = 10; - uint32 factor = 11; + uint32 interval = 10; + uint32 ease_factor = 11; uint32 reps = 12; uint32 lapses = 13; - uint32 left = 14; - sint32 odue = 15; - int64 odid = 16; + uint32 remaining_steps = 14; + sint32 original_due = 15; + int64 original_deck_id = 16; uint32 flags = 17; string data = 18; } diff --git a/pylib/anki/cards.py b/pylib/anki/cards.py index 3f1bf212f..324b0bd3e 100644 --- a/pylib/anki/cards.py +++ b/pylib/anki/cards.py @@ -56,21 +56,21 @@ class Card: self._render_output = None self._note = None self.id = c.id - self.nid = c.nid - self.did = c.did - self.ord = c.ord - self.mod = c.mtime + self.nid = c.note_id + self.did = c.deck_id + self.ord = c.template_idx + self.mod = c.mtime_secs self.usn = c.usn self.type = c.ctype self.queue = c.queue self.due = c.due - self.ivl = c.ivl - self.factor = c.factor + self.ivl = c.interval + self.factor = c.ease_factor self.reps = c.reps self.lapses = c.lapses - self.left = c.left - self.odue = c.odue - self.odid = c.odid + self.left = c.remaining_steps + self.odue = c.original_due + self.odid = c.original_deck_id self.flags = c.flags self.data = c.data @@ -88,19 +88,19 @@ class Card: # mtime & usn are set by backend card = BackendCard( id=self.id, - nid=self.nid, - did=self.did, - ord=self.ord, + note_id=self.nid, + deck_id=self.did, + template_idx=self.ord, ctype=self.type, queue=self.queue, due=self.due, - ivl=self.ivl, - factor=self.factor, + interval=self.ivl, + ease_factor=self.factor, reps=self.reps, lapses=self.lapses, - left=self.left, - odue=self.odue, - odid=self.odid, + remaining_steps=self.left, + original_due=self.odue, + original_deck_id=self.odid, flags=self.flags, data=self.data, ) diff --git a/pylib/anki/notes.py b/pylib/anki/notes.py index b265e5edc..80d86b6cf 100644 --- a/pylib/anki/notes.py +++ b/pylib/anki/notes.py @@ -44,7 +44,7 @@ class Note: def _load_from_backend_note(self, n: BackendNote) -> None: self.id = n.id self.guid = n.guid - self.mid = n.ntid + self.mid = n.notetype_id self.mod = n.mtime_secs self.usn = n.usn self.tags = list(n.tags) @@ -56,7 +56,7 @@ class Note: return BackendNote( id=self.id, guid=self.guid, - ntid=self.mid, + notetype_id=self.mid, mtime_secs=self.mod, usn=self.usn, tags=self.tags, diff --git a/rslib/src/backend/mod.rs b/rslib/src/backend/mod.rs index b90e31754..72be90733 100644 --- a/rslib/src/backend/mod.rs +++ b/rslib/src/backend/mod.rs @@ -1755,21 +1755,21 @@ impl From for pb::Card { fn from(c: Card) -> Self { pb::Card { id: c.id.0, - nid: c.nid.0, - did: c.did.0, - ord: c.ord as u32, - mtime: c.mtime.0, + note_id: c.note_id.0, + deck_id: c.deck_id.0, + template_idx: c.template_idx as u32, + mtime_secs: c.mtime.0, usn: c.usn.0, ctype: c.ctype as u32, queue: c.queue as i32, due: c.due, - ivl: c.ivl, - factor: c.factor as u32, + interval: c.interval, + ease_factor: c.ease_factor as u32, reps: c.reps, lapses: c.lapses, - left: c.left, - odue: c.odue, - odid: c.odid.0, + remaining_steps: c.remaining_steps, + original_due: c.original_due, + original_deck_id: c.original_deck_id.0, flags: c.flags as u32, data: c.data, } @@ -1783,21 +1783,21 @@ fn pbcard_to_native(c: pb::Card) -> Result { .map_err(|_| AnkiError::invalid_input("invalid card queue"))?; Ok(Card { id: CardID(c.id), - nid: NoteID(c.nid), - did: DeckID(c.did), - ord: c.ord as u16, - mtime: TimestampSecs(c.mtime), + note_id: NoteID(c.note_id), + deck_id: DeckID(c.deck_id), + template_idx: c.template_idx as u16, + mtime: TimestampSecs(c.mtime_secs), usn: Usn(c.usn), ctype, queue, due: c.due, - ivl: c.ivl, - factor: c.factor as u16, + interval: c.interval, + ease_factor: c.ease_factor as u16, reps: c.reps, lapses: c.lapses, - left: c.left, - odue: c.odue, - odid: DeckID(c.odid), + remaining_steps: c.remaining_steps, + original_due: c.original_due, + original_deck_id: DeckID(c.original_deck_id), flags: c.flags as u8, data: c.data, }) diff --git a/rslib/src/card.rs b/rslib/src/card.rs index b6884096f..9baf69c8a 100644 --- a/rslib/src/card.rs +++ b/rslib/src/card.rs @@ -52,21 +52,21 @@ pub enum CardQueue { #[derive(Debug, Clone, PartialEq)] pub struct Card { pub(crate) id: CardID, - pub(crate) nid: NoteID, - pub(crate) did: DeckID, - pub(crate) ord: u16, + pub(crate) note_id: NoteID, + pub(crate) deck_id: DeckID, + pub(crate) template_idx: u16, pub(crate) mtime: TimestampSecs, pub(crate) usn: Usn, pub(crate) ctype: CardType, pub(crate) queue: CardQueue, pub(crate) due: i32, - pub(crate) ivl: u32, - pub(crate) factor: u16, + pub(crate) interval: u32, + pub(crate) ease_factor: u16, pub(crate) reps: u32, pub(crate) lapses: u32, - pub(crate) left: u32, - pub(crate) odue: i32, - pub(crate) odid: DeckID, + pub(crate) remaining_steps: u32, + pub(crate) original_due: i32, + pub(crate) original_deck_id: DeckID, pub(crate) flags: u8, pub(crate) data: String, } @@ -75,21 +75,21 @@ impl Default for Card { fn default() -> Self { Self { id: CardID(0), - nid: NoteID(0), - did: DeckID(0), - ord: 0, + note_id: NoteID(0), + deck_id: DeckID(0), + template_idx: 0, mtime: TimestampSecs(0), usn: Usn(0), ctype: CardType::New, queue: CardQueue::New, due: 0, - ivl: 0, - factor: 0, + interval: 0, + ease_factor: 0, reps: 0, lapses: 0, - left: 0, - odue: 0, - odid: DeckID(0), + remaining_steps: 0, + original_due: 0, + original_deck_id: DeckID(0), flags: 0, data: "".to_string(), } @@ -103,17 +103,17 @@ impl Card { } pub(crate) fn return_home(&mut self, sched: SchedulerVersion) { - if self.odid.0 == 0 { + if self.original_deck_id.0 == 0 { // not in a filtered deck return; } - self.did = self.odid; - self.odid.0 = 0; - if self.odue > 0 { - self.due = self.odue; + self.deck_id = self.original_deck_id; + self.original_deck_id.0 = 0; + if self.original_due > 0 { + self.due = self.original_due; } - self.odue = 0; + self.original_due = 0; self.queue = match sched { SchedulerVersion::V1 => { @@ -166,17 +166,17 @@ impl Card { if self.ctype == CardType::Review { // reviews are removed from relearning - self.due = self.odue; - self.odue = 0; + self.due = self.original_due; + self.original_due = 0; self.queue = CardQueue::Review; } else { // other cards are reset to new self.ctype = CardType::New; self.queue = CardQueue::New; - self.ivl = 0; + self.interval = 0; self.due = 0; - self.odue = 0; - self.factor = INITIAL_EASE_FACTOR; + self.original_due = 0; + self.ease_factor = INITIAL_EASE_FACTOR; } } } @@ -196,9 +196,9 @@ impl Undoable for UpdateCardUndo { impl Card { pub fn new(nid: NoteID, ord: u16, deck_id: DeckID, due: i32) -> Self { let mut card = Card::default(); - card.nid = nid; - card.ord = ord; - card.did = deck_id; + card.note_id = nid; + card.template_idx = ord; + card.deck_id = deck_id; card.due = due; card } @@ -247,7 +247,7 @@ impl Collection { for cid in cids { if let Some(card) = self.storage.get_card(*cid)? { // fixme: undo - nids.insert(card.nid); + nids.insert(card.note_id); self.storage.remove_card(*cid)?; self.storage.add_card_grave(*cid, usn)?; } @@ -280,7 +280,7 @@ mod test { let mut col = open_test_collection(); let mut card = Card::default(); - card.ivl = 1; + card.interval = 1; col.add_card(&mut card).unwrap(); let cid = card.id; @@ -290,11 +290,11 @@ mod test { // outside of a transaction, no undo info recorded let card = col .get_and_update_card(cid, |card| { - card.ivl = 2; + card.interval = 2; Ok(()) }) .unwrap(); - assert_eq!(card.ivl, 2); + assert_eq!(card.interval, 2); assert_eq!(col.can_undo(), None); assert_eq!(col.can_redo(), None); @@ -302,7 +302,7 @@ mod test { for i in 3..=4 { col.transact(Some(CollectionOp::UpdateCard), |col| { col.get_and_update_card(cid, |card| { - card.ivl = i; + card.interval = i; Ok(()) }) .unwrap(); @@ -311,51 +311,51 @@ mod test { .unwrap(); } - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 4); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 4); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), None); // undo a step col.undo().unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 3); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 3); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), Some(CollectionOp::UpdateCard)); // and again col.undo().unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 2); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 2); assert_eq!(col.can_undo(), None); assert_eq!(col.can_redo(), Some(CollectionOp::UpdateCard)); // redo a step col.redo().unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 3); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 3); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), Some(CollectionOp::UpdateCard)); // and another col.redo().unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 4); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 4); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), None); // and undo the redo col.undo().unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 3); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 3); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), Some(CollectionOp::UpdateCard)); // if any action is performed, it should clear the redo queue col.transact(Some(CollectionOp::UpdateCard), |col| { col.get_and_update_card(cid, |card| { - card.ivl = 5; + card.interval = 5; Ok(()) }) .unwrap(); Ok(()) }) .unwrap(); - assert_eq!(col.storage.get_card(cid).unwrap().unwrap().ivl, 5); + assert_eq!(col.storage.get_card(cid).unwrap().unwrap().interval, 5); assert_eq!(col.can_undo(), Some(CollectionOp::UpdateCard)); assert_eq!(col.can_redo(), None); diff --git a/rslib/src/dbcheck.rs b/rslib/src/dbcheck.rs index 92a07beab..f7c781841 100644 --- a/rslib/src/dbcheck.rs +++ b/rslib/src/dbcheck.rs @@ -205,8 +205,8 @@ impl Collection { if let Some(deck) = decks.get(&did) { if !deck.is_filtered() { let mut card = self.storage.get_card(cid)?.unwrap(); - card.odid.0 = 0; - card.odue = 0; + card.original_deck_id.0 = 0; + card.original_due = 0; self.storage.update_card(&card)?; wrong += 1; } @@ -278,7 +278,7 @@ impl Collection { } // note type ID may have changed if we created a recovery notetype - note.ntid = nt.id; + note.notetype_id = nt.id; // write note, updating tags and generating missing cards let ctx = genctx.get_or_insert_with(|| CardGenContext::new(&nt, usn)); @@ -509,7 +509,7 @@ mod test { let cid = col.search_cards("", SortMode::NoOrder)?[0]; let mut card = col.storage.get_card(cid)?.unwrap(); card.id.0 += 1; - card.ord = 10; + card.template_idx = 10; col.storage.add_card(&mut card)?; let out = col.check_database(progress_fn)?; diff --git a/rslib/src/media/check.rs b/rslib/src/media/check.rs index 6866c4df5..de4dbe773 100644 --- a/rslib/src/media/check.rs +++ b/rslib/src/media/check.rs @@ -380,7 +380,7 @@ where } let mut note = self.ctx.storage.get_note(nid)?.unwrap(); let nt = note_types - .get(¬e.ntid) + .get(¬e.notetype_id) .ok_or_else(|| AnkiError::DBError { info: "missing note type".to_string(), kind: DBErrorKind::MissingEntity, diff --git a/rslib/src/notes.rs b/rslib/src/notes.rs index 97079be22..e43c0f049 100644 --- a/rslib/src/notes.rs +++ b/rslib/src/notes.rs @@ -36,7 +36,7 @@ pub(crate) struct TransformNoteOutput { pub struct Note { pub id: NoteID, pub guid: String, - pub ntid: NoteTypeID, + pub notetype_id: NoteTypeID, pub mtime: TimestampSecs, pub usn: Usn, pub tags: Vec, @@ -50,7 +50,7 @@ impl Note { Note { id: NoteID(0), guid: guid(), - ntid: notetype.id, + notetype_id: notetype.id, mtime: TimestampSecs(0), usn: Usn(0), tags: vec![], @@ -78,7 +78,7 @@ impl Note { /// Prepare note for saving to the database. Does not mark it as modified. pub fn prepare_for_update(&mut self, nt: &NoteType, normalize_text: bool) -> Result<()> { - assert!(nt.id == self.ntid); + assert!(nt.id == self.notetype_id); let notetype_field_count = nt.fields.len().max(1); if notetype_field_count != self.fields.len() { return Err(AnkiError::invalid_input(format!( @@ -183,7 +183,7 @@ impl From for pb::Note { pb::Note { id: n.id.0, guid: n.guid, - ntid: n.ntid.0, + notetype_id: n.notetype_id.0, mtime_secs: n.mtime.0 as u32, usn: n.usn.0, tags: n.tags, @@ -197,7 +197,7 @@ impl From for Note { Note { id: NoteID(n.id), guid: n.guid, - ntid: NoteTypeID(n.ntid), + notetype_id: NoteTypeID(n.notetype_id), mtime: TimestampSecs(n.mtime_secs as i64), usn: Usn(n.usn), tags: n.tags, @@ -248,7 +248,7 @@ impl Collection { pub fn add_note(&mut self, note: &mut Note, did: DeckID) -> Result<()> { self.transact(None, |col| { let nt = col - .get_notetype(note.ntid)? + .get_notetype(note.notetype_id)? .ok_or_else(|| AnkiError::invalid_input("missing note type"))?; let ctx = CardGenContext::new(&nt, col.usn()?); let norm = col.normalize_note_text(); @@ -282,7 +282,7 @@ impl Collection { self.transact(None, |col| { let nt = col - .get_notetype(note.ntid)? + .get_notetype(note.notetype_id)? .ok_or_else(|| AnkiError::invalid_input("missing note type"))?; let ctx = CardGenContext::new(&nt, col.usn()?); let norm = col.normalize_note_text(); @@ -434,9 +434,9 @@ impl Collection { Ok(DuplicateState::Empty) } else { let csum = field_checksum(&stripped); - for field in self - .storage - .note_fields_by_checksum(note.id, note.ntid, csum)? + for field in + self.storage + .note_fields_by_checksum(note.id, note.notetype_id, csum)? { if strip_html_preserving_image_filenames(&field) == stripped { return Ok(DuplicateState::Duplicate); diff --git a/rslib/src/notetype/render.rs b/rslib/src/notetype/render.rs index 6cb8f52b3..3e18f69ec 100644 --- a/rslib/src/notetype/render.rs +++ b/rslib/src/notetype/render.rs @@ -26,13 +26,13 @@ impl Collection { .ok_or_else(|| AnkiError::invalid_input("no such card"))?; let note = self .storage - .get_note(card.nid)? + .get_note(card.note_id)? .ok_or_else(|| AnkiError::invalid_input("no such note"))?; let nt = self - .get_notetype(note.ntid)? + .get_notetype(note.notetype_id)? .ok_or_else(|| AnkiError::invalid_input("no such notetype"))?; let template = match nt.config.kind() { - NoteTypeKind::Normal => nt.templates.get(card.ord as usize), + NoteTypeKind::Normal => nt.templates.get(card.template_idx as usize), NoteTypeKind::Cloze => nt.templates.get(0), } .ok_or_else(|| AnkiError::invalid_input("missing template"))?; @@ -52,7 +52,7 @@ impl Collection { ) -> Result { let card = self.existing_or_synthesized_card(note.id, template.ord, card_ord)?; let nt = self - .get_notetype(note.ntid)? + .get_notetype(note.notetype_id)? .ok_or_else(|| AnkiError::invalid_input("no such notetype"))?; if fill_empty { @@ -77,7 +77,7 @@ impl Collection { // no existing card; synthesize one let mut card = Card::default(); - card.ord = card_ord; + card.template_idx = card_ord; Ok(card) } @@ -94,7 +94,7 @@ impl Collection { let card_num; self.add_special_fields(&mut field_map, note, card, &nt, template)?; // due to lifetime restrictions we need to add card number here - card_num = format!("c{}", card.ord + 1); + card_num = format!("c{}", card.template_idx + 1); field_map.entry(&card_num).or_insert_with(|| "1".into()); let (qfmt, afmt) = if browser { @@ -109,8 +109,14 @@ impl Collection { ) }; - let (qnodes, anodes) = - render_card(qfmt, afmt, &field_map, card.ord, nt.is_cloze(), &self.i18n)?; + let (qnodes, anodes) = render_card( + qfmt, + afmt, + &field_map, + card.template_idx, + nt.is_cloze(), + &self.i18n, + )?; Ok(RenderCardOutput { qnodes, anodes }) } @@ -127,7 +133,11 @@ impl Collection { map.entry("Tags").or_insert_with(|| tags.into()); map.entry("Type").or_insert_with(|| nt.name.clone().into()); let deck_name: Cow = self - .get_deck(if card.odid.0 > 0 { card.odid } else { card.did })? + .get_deck(if card.original_deck_id.0 > 0 { + card.original_deck_id + } else { + card.deck_id + })? .map(|d| d.human_name().into()) .unwrap_or_else(|| "(Deck)".into()); let subdeck_name = deck_name.rsplit("::").next().unwrap(); diff --git a/rslib/src/sched/bury_and_suspend.rs b/rslib/src/sched/bury_and_suspend.rs index 11cce7bdf..fe445f580 100644 --- a/rslib/src/sched/bury_and_suspend.rs +++ b/rslib/src/sched/bury_and_suspend.rs @@ -23,7 +23,11 @@ impl Card { } else { self.queue = match self.ctype { CardType::Learn | CardType::Relearn => { - let original_due = if self.odue > 0 { self.odue } else { self.due }; + let original_due = if self.original_due > 0 { + self.original_due + } else { + self.due + }; if original_due > 1_000_000_000 { // previous interval was in seconds CardQueue::Learn diff --git a/rslib/src/stats/card.rs b/rslib/src/stats/card.rs index 95ef867ec..c5a07bb12 100644 --- a/rslib/src/stats/card.rs +++ b/rslib/src/stats/card.rs @@ -65,12 +65,14 @@ impl Collection { let card = self.storage.get_card(cid)?.ok_or(AnkiError::NotFound)?; let note = self .storage - .get_note(card.nid)? + .get_note(card.note_id)? + .ok_or(AnkiError::NotFound)?; + let nt = self + .get_notetype(note.notetype_id)? .ok_or(AnkiError::NotFound)?; - let nt = self.get_notetype(note.ntid)?.ok_or(AnkiError::NotFound)?; let deck = self .storage - .get_deck(card.did)? + .get_deck(card.deck_id)? .ok_or(AnkiError::NotFound)?; let revlog = self.storage.get_revlog_entries_for_card(card.id)?; @@ -104,16 +106,16 @@ impl Collection { first_review: revlog.first().map(|e| e.id.as_secs()), latest_review: revlog.last().map(|e| e.id.as_secs()), due, - interval_secs: card.ivl * 86_400, - ease: (card.factor as u32) / 10, + interval_secs: card.interval * 86_400, + ease: (card.ease_factor as u32) / 10, reviews: card.reps, lapses: card.lapses, average_secs, total_secs, - card_type: nt.get_template(card.ord)?.name.clone(), + card_type: nt.get_template(card.template_idx)?.name.clone(), note_type: nt.name.clone(), deck: deck.human_name(), - nid: card.nid, + nid: card.note_id, cid: card.id, revlog: revlog.into_iter().map(Into::into).collect(), }) diff --git a/rslib/src/storage/card/mod.rs b/rslib/src/storage/card/mod.rs index 8535ab88f..521b5ed81 100644 --- a/rslib/src/storage/card/mod.rs +++ b/rslib/src/storage/card/mod.rs @@ -41,21 +41,21 @@ impl FromSql for CardQueue { fn row_to_card(row: &Row) -> result::Result { Ok(Card { id: row.get(0)?, - nid: row.get(1)?, - did: row.get(2)?, - ord: row.get(3)?, + note_id: row.get(1)?, + deck_id: row.get(2)?, + template_idx: row.get(3)?, mtime: row.get(4)?, usn: row.get(5)?, ctype: row.get(6)?, queue: row.get(7)?, due: row.get(8).ok().unwrap_or_default(), - ivl: row.get(9)?, - factor: row.get(10)?, + interval: row.get(9)?, + ease_factor: row.get(10)?, reps: row.get(11)?, lapses: row.get(12)?, - left: row.get(13)?, - odue: row.get(14).ok().unwrap_or_default(), - odid: row.get(15)?, + remaining_steps: row.get(13)?, + original_due: row.get(14).ok().unwrap_or_default(), + original_deck_id: row.get(15)?, flags: row.get(16)?, data: row.get(17)?, }) @@ -73,21 +73,21 @@ impl super::SqliteStorage { pub(crate) fn update_card(&self, card: &Card) -> Result<()> { let mut stmt = self.db.prepare_cached(include_str!("update_card.sql"))?; stmt.execute(params![ - card.nid, - card.did, - card.ord, + card.note_id, + card.deck_id, + card.template_idx, card.mtime, card.usn, card.ctype as u8, card.queue as i8, card.due, - card.ivl, - card.factor, + card.interval, + card.ease_factor, card.reps, card.lapses, - card.left, - card.odue, - card.odid, + card.remaining_steps, + card.original_due, + card.original_deck_id, card.flags, card.data, card.id, @@ -100,21 +100,21 @@ impl super::SqliteStorage { let mut stmt = self.db.prepare_cached(include_str!("add_card.sql"))?; stmt.execute(params![ now, - card.nid, - card.did, - card.ord, + card.note_id, + card.deck_id, + card.template_idx, card.mtime, card.usn, card.ctype as u8, card.queue as i8, card.due, - card.ivl, - card.factor, + card.interval, + card.ease_factor, card.reps, card.lapses, - card.left, - card.odue, - card.odid, + card.remaining_steps, + card.original_due, + card.original_deck_id, card.flags, card.data, ])?; @@ -127,21 +127,21 @@ impl super::SqliteStorage { let mut stmt = self.db.prepare_cached(include_str!("add_or_update.sql"))?; stmt.execute(params![ card.id, - card.nid, - card.did, - card.ord, + card.note_id, + card.deck_id, + card.template_idx, card.mtime, card.usn, card.ctype as u8, card.queue as i8, card.due, - card.ivl, - card.factor, + card.interval, + card.ease_factor, card.reps, card.lapses, - card.left, - card.odue, - card.odid, + card.remaining_steps, + card.original_due, + card.original_deck_id, card.flags, card.data, ])?; diff --git a/rslib/src/storage/note/mod.rs b/rslib/src/storage/note/mod.rs index 7771839f4..c2df8e5b9 100644 --- a/rslib/src/storage/note/mod.rs +++ b/rslib/src/storage/note/mod.rs @@ -22,7 +22,7 @@ fn row_to_note(row: &Row) -> Result { Ok(Note { id: row.get(0)?, guid: row.get(1)?, - ntid: row.get(2)?, + notetype_id: row.get(2)?, mtime: row.get(3)?, usn: row.get(4)?, tags: split_tags(row.get_raw(5).as_str()?) @@ -49,7 +49,7 @@ impl super::SqliteStorage { let mut stmt = self.db.prepare_cached(include_str!("update.sql"))?; stmt.execute(params![ note.guid, - note.ntid, + note.notetype_id, note.mtime, note.usn, join_tags(¬e.tags), @@ -67,7 +67,7 @@ impl super::SqliteStorage { stmt.execute(params![ TimestampMillis::now(), note.guid, - note.ntid, + note.notetype_id, note.mtime, note.usn, join_tags(¬e.tags), @@ -85,7 +85,7 @@ impl super::SqliteStorage { stmt.execute(params![ note.id, note.guid, - note.ntid, + note.notetype_id, note.mtime, note.usn, join_tags(¬e.tags), diff --git a/rslib/src/sync/mod.rs b/rslib/src/sync/mod.rs index 961704600..d8b718912 100644 --- a/rslib/src/sync/mod.rs +++ b/rslib/src/sync/mod.rs @@ -945,7 +945,7 @@ impl Collection { if proceed { let mut note: Note = entry.into(); let nt = self - .get_notetype(note.ntid)? + .get_notetype(note.notetype_id)? .ok_or_else(|| AnkiError::invalid_input("note missing notetype"))?; note.prepare_for_update(&nt, false)?; self.storage.add_or_update_note(¬e)?; @@ -1065,21 +1065,21 @@ impl From for Card { fn from(e: CardEntry) -> Self { Card { id: e.id, - nid: e.nid, - did: e.did, - ord: e.ord, + note_id: e.nid, + deck_id: e.did, + template_idx: e.ord, mtime: e.mtime, usn: e.usn, ctype: e.ctype, queue: e.queue, due: e.due, - ivl: e.ivl, - factor: e.factor, + interval: e.ivl, + ease_factor: e.factor, reps: e.reps, lapses: e.lapses, - left: e.left, - odue: e.odue, - odid: e.odid, + remaining_steps: e.left, + original_due: e.odue, + original_deck_id: e.odid, flags: e.flags, data: e.data, } @@ -1090,21 +1090,21 @@ impl From for CardEntry { fn from(e: Card) -> Self { CardEntry { id: e.id, - nid: e.nid, - did: e.did, - ord: e.ord, + nid: e.note_id, + did: e.deck_id, + ord: e.template_idx, mtime: e.mtime, usn: e.usn, ctype: e.ctype, queue: e.queue, due: e.due, - ivl: e.ivl, - factor: e.factor, + ivl: e.interval, + factor: e.ease_factor, reps: e.reps, lapses: e.lapses, - left: e.left, - odue: e.odue, - odid: e.odid, + left: e.remaining_steps, + odue: e.original_due, + odid: e.original_deck_id, flags: e.flags, data: e.data, } @@ -1116,7 +1116,7 @@ impl From for Note { Note { id: e.id, guid: e.guid, - ntid: e.ntid, + notetype_id: e.ntid, mtime: e.mtime, usn: e.usn, tags: split_tags(&e.tags).map(ToString::to_string).collect(), @@ -1132,7 +1132,7 @@ impl From for NoteEntry { NoteEntry { id: e.id, guid: e.guid, - ntid: e.ntid, + ntid: e.notetype_id, mtime: e.mtime, usn: e.usn, tags: join_tags(&e.tags), diff --git a/ts/src/stats/card-counts.ts b/ts/src/stats/card-counts.ts index 833588d5c..cab1517c5 100644 --- a/ts/src/stats/card-counts.ts +++ b/ts/src/stats/card-counts.ts @@ -39,7 +39,7 @@ export function gatherData(data: pb.BackendProto.GraphsOut, i18n: I18n): GraphDa newCards += 1; break; case CardQueue.Review: - if (card.ivl >= 21) { + if (card.interval >= 21) { mature += 1; break; } diff --git a/ts/src/stats/ease.ts b/ts/src/stats/ease.ts index 5a22d1f9f..97b38bf76 100644 --- a/ts/src/stats/ease.ts +++ b/ts/src/stats/ease.ts @@ -22,7 +22,7 @@ export interface GraphData { export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { const eases = (data.cards as pb.BackendProto.Card[]) .filter((c) => c.queue == CardQueue.Review) - .map((c) => c.factor / 10); + .map((c) => c.easeFactor / 10); return { eases }; } diff --git a/ts/src/stats/future-due.ts b/ts/src/stats/future-due.ts index 13d6a46bc..615e58573 100644 --- a/ts/src/stats/future-due.ts +++ b/ts/src/stats/future-due.ts @@ -40,7 +40,7 @@ export function gatherData(data: pb.BackendProto.GraphsOut): GraphData { // - testing just odue fails on day 1 // - testing just odid fails on lapsed cards that // have due calculated at regraduation time - const due = c.odid && c.odue ? c.odue : c.due; + const due = c.originalDeckId && c.originalDue ? c.originalDue : c.due; const dueDay = due - data.daysElapsed; if (dueDay < 0) { haveBacklog = true; diff --git a/ts/src/stats/intervals.ts b/ts/src/stats/intervals.ts index c72a69b09..18275c03d 100644 --- a/ts/src/stats/intervals.ts +++ b/ts/src/stats/intervals.ts @@ -30,7 +30,7 @@ export enum IntervalRange { export function gatherIntervalData(data: pb.BackendProto.GraphsOut): IntervalGraphData { const intervals = (data.cards as pb.BackendProto.Card[]) .filter((c) => c.queue == CardQueue.Review) - .map((c) => c.ivl); + .map((c) => c.interval); return { intervals }; }