mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add note reps column
This commit is contained in:
parent
18e33f24d3
commit
32e538d0db
7 changed files with 21 additions and 3 deletions
|
@ -725,6 +725,7 @@ class NoteState(ItemState):
|
||||||
("noteEase", tr.browsing_average_ease()),
|
("noteEase", tr.browsing_average_ease()),
|
||||||
("noteFld", tr.browsing_sort_field()),
|
("noteFld", tr.browsing_sort_field()),
|
||||||
("noteMod", tr.search_note_modified()),
|
("noteMod", tr.search_note_modified()),
|
||||||
|
("noteReps", tr.scheduling_reviews()),
|
||||||
("noteTags", tr.editing_tags()),
|
("noteTags", tr.editing_tags()),
|
||||||
]
|
]
|
||||||
self._columns.sort(key=itemgetter(1))
|
self._columns.sort(key=itemgetter(1))
|
||||||
|
|
|
@ -812,6 +812,7 @@ message SortOrder {
|
||||||
NOTE_EASE = 2;
|
NOTE_EASE = 2;
|
||||||
NOTE_MOD = 3;
|
NOTE_MOD = 3;
|
||||||
NOTE_FIELD = 4;
|
NOTE_FIELD = 4;
|
||||||
|
NOTE_REPS = 15;
|
||||||
NOTE_TAGS = 5;
|
NOTE_TAGS = 5;
|
||||||
NOTETYPE = 6;
|
NOTETYPE = 6;
|
||||||
CARD_MOD = 7;
|
CARD_MOD = 7;
|
||||||
|
|
|
@ -102,6 +102,7 @@ impl From<SortKindProto> for SortKind {
|
||||||
SortKindProto::NoteEase => SortKind::NoteEase,
|
SortKindProto::NoteEase => SortKind::NoteEase,
|
||||||
SortKindProto::NoteMod => SortKind::NoteMod,
|
SortKindProto::NoteMod => SortKind::NoteMod,
|
||||||
SortKindProto::NoteField => SortKind::NoteField,
|
SortKindProto::NoteField => SortKind::NoteField,
|
||||||
|
SortKindProto::NoteReps => SortKind::NoteReps,
|
||||||
SortKindProto::NoteTags => SortKind::NoteTags,
|
SortKindProto::NoteTags => SortKind::NoteTags,
|
||||||
SortKindProto::Notetype => SortKind::Notetype,
|
SortKindProto::Notetype => SortKind::Notetype,
|
||||||
SortKindProto::CardMod => SortKind::CardMod,
|
SortKindProto::CardMod => SortKind::CardMod,
|
||||||
|
|
|
@ -429,6 +429,7 @@ impl RowContext for NoteRowContext<'_> {
|
||||||
"noteEase" => self.note_ease_str(),
|
"noteEase" => self.note_ease_str(),
|
||||||
"noteFld" => self.note_field_str(),
|
"noteFld" => self.note_field_str(),
|
||||||
"noteMod" => self.note.mtime.date_string(),
|
"noteMod" => self.note.mtime.date_string(),
|
||||||
|
"noteReps" => self.cards.iter().map(|c| c.reps).sum::<u32>().to_string(),
|
||||||
"noteTags" => self.note.tags.join(" "),
|
"noteTags" => self.note.tags.join(" "),
|
||||||
_ => "".to_string(),
|
_ => "".to_string(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -278,6 +278,7 @@ pub enum SortKind {
|
||||||
NoteMod,
|
NoteMod,
|
||||||
#[serde(rename = "noteFld")]
|
#[serde(rename = "noteFld")]
|
||||||
NoteField,
|
NoteField,
|
||||||
|
NoteReps,
|
||||||
#[serde(rename = "note")]
|
#[serde(rename = "note")]
|
||||||
Notetype,
|
Notetype,
|
||||||
NoteTags,
|
NoteTags,
|
||||||
|
|
|
@ -94,6 +94,7 @@ impl SortKind {
|
||||||
| SortKind::NoteMod
|
| SortKind::NoteMod
|
||||||
| SortKind::NoteField
|
| SortKind::NoteField
|
||||||
| SortKind::Notetype
|
| SortKind::Notetype
|
||||||
|
| SortKind::NoteReps
|
||||||
| SortKind::NoteTags => RequiredTable::Notes,
|
| SortKind::NoteTags => RequiredTable::Notes,
|
||||||
SortKind::CardTemplate => RequiredTable::CardsAndNotes,
|
SortKind::CardTemplate => RequiredTable::CardsAndNotes,
|
||||||
SortKind::CardMod
|
SortKind::CardMod
|
||||||
|
@ -250,11 +251,12 @@ fn card_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
|
|
||||||
fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
fn note_order_from_sortkind(kind: SortKind) -> Cow<'static, str> {
|
||||||
match kind {
|
match kind {
|
||||||
SortKind::NoteCards => "(select pos from sort_order where nid = n.id) asc".into(),
|
SortKind::NoteCards | SortKind::NoteEase | SortKind::NoteReps => {
|
||||||
|
"(select pos from sort_order where nid = n.id) asc".into()
|
||||||
|
}
|
||||||
SortKind::NoteCreation => "n.id asc".into(),
|
SortKind::NoteCreation => "n.id asc".into(),
|
||||||
SortKind::NoteEase => "(select pos from sort_order where nid = n.id) asc".into(),
|
|
||||||
SortKind::NoteMod => "n.mod asc".into(),
|
|
||||||
SortKind::NoteField => "n.sfld collate nocase asc".into(),
|
SortKind::NoteField => "n.sfld collate nocase asc".into(),
|
||||||
|
SortKind::NoteMod => "n.mod asc".into(),
|
||||||
SortKind::NoteTags => "n.tags asc".into(),
|
SortKind::NoteTags => "n.tags asc".into(),
|
||||||
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
SortKind::Notetype => "(select pos from sort_order where ntid = n.mid) asc".into(),
|
||||||
_ => "".into(),
|
_ => "".into(),
|
||||||
|
@ -269,6 +271,7 @@ fn prepare_sort(col: &mut Collection, kind: SortKind) -> Result<()> {
|
||||||
CardTemplate => include_str!("template_order.sql"),
|
CardTemplate => include_str!("template_order.sql"),
|
||||||
NoteCards => include_str!("note_cards_order.sql"),
|
NoteCards => include_str!("note_cards_order.sql"),
|
||||||
NoteEase => include_str!("note_ease_order.sql"),
|
NoteEase => include_str!("note_ease_order.sql"),
|
||||||
|
NoteReps => include_str!("note_reps_order.sql"),
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
rslib/src/search/note_reps_order.sql
Normal file
10
rslib/src/search/note_reps_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(reps);
|
Loading…
Reference in a new issue