mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
move filter code into scheduler/
This commit is contained in:
parent
b5c58ff8e6
commit
2a168adb66
5 changed files with 45 additions and 43 deletions
38
rslib/src/decks/filtered.rs
Normal file
38
rslib/src/decks/filtered.rs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
pub use crate::backend_proto::{
|
||||||
|
deck_kind::Kind as DeckKind, Deck as DeckProto, DeckCommon, DeckKind as DeckKindProto,
|
||||||
|
FilteredDeck, NormalDeck,
|
||||||
|
};
|
||||||
|
use crate::decks::FilteredSearchTerm;
|
||||||
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
impl Deck {
|
||||||
|
pub fn new_filtered() -> Deck {
|
||||||
|
let mut filt = FilteredDeck::default();
|
||||||
|
filt.search_terms.push(FilteredSearchTerm {
|
||||||
|
search: "".into(),
|
||||||
|
limit: 100,
|
||||||
|
order: 0,
|
||||||
|
});
|
||||||
|
filt.preview_delay = 10;
|
||||||
|
filt.reschedule = true;
|
||||||
|
Deck {
|
||||||
|
id: DeckID(0),
|
||||||
|
name: "".into(),
|
||||||
|
mtime_secs: TimestampSecs(0),
|
||||||
|
usn: Usn(0),
|
||||||
|
common: DeckCommon {
|
||||||
|
study_collapsed: true,
|
||||||
|
browser_collapsed: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
kind: DeckKind::Filtered(filt),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_filtered(&self) -> bool {
|
||||||
|
matches!(self.kind, DeckKind::Filtered(_))
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
mod counts;
|
mod counts;
|
||||||
|
mod filtered;
|
||||||
mod schema11;
|
mod schema11;
|
||||||
mod tree;
|
mod tree;
|
||||||
pub(crate) mod undo;
|
pub(crate) mod undo;
|
||||||
|
|
|
@ -15,7 +15,6 @@ pub mod dbcheck;
|
||||||
pub mod deckconf;
|
pub mod deckconf;
|
||||||
pub mod decks;
|
pub mod decks;
|
||||||
pub mod err;
|
pub mod err;
|
||||||
pub mod filtered;
|
|
||||||
pub mod findreplace;
|
pub mod findreplace;
|
||||||
mod fluent_proto;
|
mod fluent_proto;
|
||||||
pub mod i18n;
|
pub mod i18n;
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
pub use crate::backend_proto::{
|
use crate::decks::{FilteredDeck, FilteredSearchOrder, FilteredSearchTerm};
|
||||||
deck_kind::Kind as DeckKind, Deck as DeckProto, DeckCommon, DeckKind as DeckKindProto,
|
|
||||||
FilteredDeck, NormalDeck,
|
|
||||||
};
|
|
||||||
use crate::decks::{Deck, DeckID};
|
|
||||||
use crate::decks::{FilteredSearchOrder, FilteredSearchTerm};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
card::{Card, CardID, CardQueue, CardType},
|
card::{CardQueue, CardType},
|
||||||
collection::Collection,
|
|
||||||
config::SchedulerVersion,
|
config::SchedulerVersion,
|
||||||
err::Result,
|
prelude::*,
|
||||||
prelude::AnkiError,
|
|
||||||
search::SortMode,
|
search::SortMode,
|
||||||
timestamp::TimestampSecs,
|
|
||||||
types::Usn,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Card {
|
impl Card {
|
||||||
|
@ -131,35 +122,6 @@ impl Card {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deck {
|
|
||||||
pub fn new_filtered() -> Deck {
|
|
||||||
let mut filt = FilteredDeck::default();
|
|
||||||
filt.search_terms.push(FilteredSearchTerm {
|
|
||||||
search: "".into(),
|
|
||||||
limit: 100,
|
|
||||||
order: 0,
|
|
||||||
});
|
|
||||||
filt.preview_delay = 10;
|
|
||||||
filt.reschedule = true;
|
|
||||||
Deck {
|
|
||||||
id: DeckID(0),
|
|
||||||
name: "".into(),
|
|
||||||
mtime_secs: TimestampSecs(0),
|
|
||||||
usn: Usn(0),
|
|
||||||
common: DeckCommon {
|
|
||||||
study_collapsed: true,
|
|
||||||
browser_collapsed: true,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
kind: DeckKind::Filtered(filt),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn is_filtered(&self) -> bool {
|
|
||||||
matches!(self.kind, DeckKind::Filtered(_))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct DeckFilterContext<'a> {
|
pub(crate) struct DeckFilterContext<'a> {
|
||||||
pub target_deck: DeckID,
|
pub target_deck: DeckID,
|
||||||
pub config: &'a FilteredDeck,
|
pub config: &'a FilteredDeck,
|
||||||
|
@ -172,7 +134,8 @@ impl Collection {
|
||||||
pub fn empty_filtered_deck(&mut self, did: DeckID) -> Result<()> {
|
pub fn empty_filtered_deck(&mut self, did: DeckID) -> Result<()> {
|
||||||
self.transact_no_undo(|col| col.return_all_cards_in_filtered_deck(did))
|
self.transact_no_undo(|col| col.return_all_cards_in_filtered_deck(did))
|
||||||
}
|
}
|
||||||
pub(super) fn return_all_cards_in_filtered_deck(&mut self, did: DeckID) -> Result<()> {
|
|
||||||
|
pub(crate) fn return_all_cards_in_filtered_deck(&mut self, did: DeckID) -> Result<()> {
|
||||||
let cids = self.storage.all_cards_in_single_deck(did)?;
|
let cids = self.storage.all_cards_in_single_deck(did)?;
|
||||||
self.return_cards_to_home_deck(&cids)
|
self.return_cards_to_home_deck(&cids)
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ use crate::{collection::Collection, config::SchedulerVersion, err::Result, prelu
|
||||||
pub mod answering;
|
pub mod answering;
|
||||||
pub mod bury_and_suspend;
|
pub mod bury_and_suspend;
|
||||||
pub(crate) mod congrats;
|
pub(crate) mod congrats;
|
||||||
|
mod filtered;
|
||||||
mod learning;
|
mod learning;
|
||||||
pub mod new;
|
pub mod new;
|
||||||
pub(crate) mod queue;
|
pub(crate) mod queue;
|
||||||
|
|
Loading…
Reference in a new issue