Add note lapses column
This commit is contained in:
parent
32e538d0db
commit
4933b922f7
@ -724,6 +724,7 @@ class NoteState(ItemState):
|
||||
("noteCrt", tr.browsing_created()),
|
||||
("noteEase", tr.browsing_average_ease()),
|
||||
("noteFld", tr.browsing_sort_field()),
|
||||
("noteLapses", tr.scheduling_lapses()),
|
||||
("noteMod", tr.search_note_modified()),
|
||||
("noteReps", tr.scheduling_reviews()),
|
||||
("noteTags", tr.editing_tags()),
|
||||
|
@ -810,19 +810,20 @@ message SortOrder {
|
||||
NOTE_CARDS = 0;
|
||||
NOTE_CREATION = 1;
|
||||
NOTE_EASE = 2;
|
||||
NOTE_MOD = 3;
|
||||
NOTE_FIELD = 4;
|
||||
NOTE_REPS = 15;
|
||||
NOTE_TAGS = 5;
|
||||
NOTETYPE = 6;
|
||||
CARD_MOD = 7;
|
||||
CARD_REPS = 8;
|
||||
CARD_DUE = 9;
|
||||
CARD_EASE = 10;
|
||||
CARD_LAPSES = 11;
|
||||
CARD_INTERVAL = 12;
|
||||
CARD_DECK = 13;
|
||||
CARD_TEMPLATE = 14;
|
||||
NOTE_FIELD = 3;
|
||||
NOTE_LAPSES = 4;
|
||||
NOTE_MOD = 5;
|
||||
NOTE_REPS = 6;
|
||||
NOTE_TAGS = 7;
|
||||
NOTETYPE = 8;
|
||||
CARD_MOD = 9;
|
||||
CARD_REPS = 10;
|
||||
CARD_DUE = 11;
|
||||
CARD_EASE = 12;
|
||||
CARD_LAPSES = 13;
|
||||
CARD_INTERVAL = 14;
|
||||
CARD_DECK = 15;
|
||||
CARD_TEMPLATE = 16;
|
||||
}
|
||||
Kind kind = 1;
|
||||
bool reverse = 2;
|
||||
|
@ -100,6 +100,7 @@ impl From<SortKindProto> for SortKind {
|
||||
SortKindProto::NoteCards => SortKind::NoteCards,
|
||||
SortKindProto::NoteCreation => SortKind::NoteCreation,
|
||||
SortKindProto::NoteEase => SortKind::NoteEase,
|
||||
SortKindProto::NoteLapses => SortKind::NoteLapses,
|
||||
SortKindProto::NoteMod => SortKind::NoteMod,
|
||||
SortKindProto::NoteField => SortKind::NoteField,
|
||||
SortKindProto::NoteReps => SortKind::NoteReps,
|
||||
|
@ -428,6 +428,7 @@ impl RowContext for NoteRowContext<'_> {
|
||||
"noteCrt" => self.note_creation_str(),
|
||||
"noteEase" => self.note_ease_str(),
|
||||
"noteFld" => self.note_field_str(),
|
||||
"noteLapses" => self.cards.iter().map(|c| c.lapses).sum::<u32>().to_string(),
|
||||
"noteMod" => self.note.mtime.date_string(),
|
||||
"noteReps" => self.cards.iter().map(|c| c.reps).sum::<u32>().to_string(),
|
||||
"noteTags" => self.note.tags.join(" "),
|
||||
|
@ -275,6 +275,7 @@ pub enum SortKind {
|
||||
#[serde(rename = "noteCrt")]
|
||||
NoteCreation,
|
||||
NoteEase,
|
||||
NoteLapses,
|
||||
NoteMod,
|
||||
#[serde(rename = "noteFld")]
|
||||
NoteField,
|
||||
|
@ -91,11 +91,12 @@ impl SortKind {
|
||||
SortKind::NoteCards
|
||||
| SortKind::NoteCreation
|
||||
| SortKind::NoteEase
|
||||
| SortKind::NoteMod
|
||||
| SortKind::NoteField
|
||||
| SortKind::Notetype
|
||||
| SortKind::NoteLapses
|
||||
| SortKind::NoteMod
|
||||
| SortKind::NoteReps
|
||||
| SortKind::NoteTags => RequiredTable::Notes,
|
||||
| SortKind::NoteTags
|
||||
| SortKind::Notetype => RequiredTable::Notes,
|
||||
SortKind::CardTemplate => RequiredTable::CardsAndNotes,
|
||||
SortKind::CardMod
|
||||
| SortKind::CardReps
|
||||
@ -251,7 +252,7 @@ fn card_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||
|
||||
fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||
match kind {
|
||||
SortKind::NoteCards | SortKind::NoteEase | SortKind::NoteReps => {
|
||||
SortKind::NoteCards | SortKind::NoteEase | SortKind::NoteLapses | SortKind::NoteReps => {
|
||||
"(select pos from sort_order where nid = n.id) asc".into()
|
||||
}
|
||||
SortKind::NoteCreation => "n.id asc".into(),
|
||||
@ -267,11 +268,12 @@ fn prepare_sort(col: &mut Collection, kind: SortKind) -> Result<()> {
|
||||
use SortKind::*;
|
||||
let sql = match kind {
|
||||
CardDeck => include_str!("deck_order.sql"),
|
||||
Notetype => include_str!("notetype_order.sql"),
|
||||
CardTemplate => include_str!("template_order.sql"),
|
||||
NoteCards => include_str!("note_cards_order.sql"),
|
||||
NoteEase => include_str!("note_ease_order.sql"),
|
||||
NoteLapses => include_str!("note_lapses_order.sql"),
|
||||
NoteReps => include_str!("note_reps_order.sql"),
|
||||
Notetype => include_str!("notetype_order.sql"),
|
||||
_ => return Ok(()),
|
||||
};
|
||||
|
||||
|
10
rslib/src/search/note_lapses_order.sql
Normal file
10
rslib/src/search/note_lapses_order.sql
Normal file
@ -0,0 +1,10 @@
|
||||
DROP TABLE IF EXISTS sort_order;
|
||||
CREATE TEMPORARY TABLE sort_order (
|
||||
pos integer PRIMARY KEY,
|
||||
nid integer NOT NULL UNIQUE
|
||||
);
|
||||
INSERT INTO sort_order (nid)
|
||||
SELECT nid
|
||||
FROM cards
|
||||
GROUP BY nid
|
||||
ORDER BY SUM(lapses);
|
Loading…
Reference in New Issue
Block a user