From 73b897c7548b8853fd771bac8a0ea79224d96f4a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 30 Jan 2021 10:54:21 +1000 Subject: [PATCH] rename FilterToSearchIn in backend to match frontend --- pylib/anki/rsbackend.py | 6 +++--- qt/.pylintrc | 2 +- rslib/backend.proto | 4 ++-- rslib/src/backend/mod.rs | 44 ++++++++++++++++++++-------------------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pylib/anki/rsbackend.py b/pylib/anki/rsbackend.py index 90ed6a815..994285484 100644 --- a/pylib/anki/rsbackend.py +++ b/pylib/anki/rsbackend.py @@ -47,9 +47,9 @@ TagTreeNode = pb.TagTreeNode NoteType = pb.NoteType DeckTreeNode = pb.DeckTreeNode StockNoteType = pb.StockNoteType -SearchTerm = pb.FilterToSearchIn -Flag = pb.FilterToSearchIn.Flag -DupeIn = pb.FilterToSearchIn.DupeIn +SearchTerm = pb.SearchTerm +Flag = pb.SearchTerm.Flag +DupeIn = pb.SearchTerm.DupeIn NoteIDs = pb.NoteIDs BackendNoteTypeID = pb.NoteTypeID ConcatSeparator = pb.ConcatenateSearchesIn.Separator diff --git a/qt/.pylintrc b/qt/.pylintrc index 557c113be..33e90dfdc 100644 --- a/qt/.pylintrc +++ b/qt/.pylintrc @@ -5,7 +5,7 @@ ignore = forms,hooks_gen.py [TYPECHECK] ignored-modules=win32file,pywintypes,socket,win32pipe,winrt,pyaudio -ignored-classes=FilterToSearchIn +ignored-classes=SearchTerm [REPORTS] output-format=colorized diff --git a/rslib/backend.proto b/rslib/backend.proto index 0bb4b5d97..658e2952c 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -88,7 +88,7 @@ service BackendService { // searching - rpc FilterToSearch(FilterToSearchIn) returns (String); + rpc FilterToSearch(SearchTerm) returns (String); rpc NormalizeSearch(String) returns (String); rpc SearchCards(SearchCardsIn) returns (SearchCardsOut); rpc SearchNotes(SearchNotesIn) returns (SearchNotesOut); @@ -764,7 +764,7 @@ message BuiltinSearchOrder { bool reverse = 2; } -message FilterToSearchIn { +message SearchTerm { message DupeIn { NoteTypeID mid = 1; string text = 2; diff --git a/rslib/src/backend/mod.rs b/rslib/src/backend/mod.rs index f536f431e..c86f57063 100644 --- a/rslib/src/backend/mod.rs +++ b/rslib/src/backend/mod.rs @@ -290,10 +290,10 @@ impl From for DeckConfID { } } -impl From for Node<'_> { - fn from(msg: pb::FilterToSearchIn) -> Self { - use pb::filter_to_search_in::Filter; - use pb::filter_to_search_in::Flag; +impl From for Node<'_> { + fn from(msg: pb::SearchTerm) -> Self { + use pb::search_term::Filter; + use pb::search_term::Flag; match msg.filter.unwrap_or(Filter::WholeCollection(true)) { Filter::Tag(s) => Node::Search(SearchNode::Tag( escape_anki_wildcards(&s).into_owned().into(), @@ -329,7 +329,7 @@ impl From for Node<'_> { Filter::WholeCollection(_) => Node::Search(SearchNode::WholeCollection), Filter::CurrentDeck(_) => Node::Search(SearchNode::Deck("current".into())), Filter::CardState(state) => Node::Search(SearchNode::State( - pb::filter_to_search_in::CardState::from_i32(state) + pb::search_term::CardState::from_i32(state) .unwrap_or_default() .into(), )), @@ -354,28 +354,28 @@ impl From for BoolSeparator { } } -impl From for EaseKind { - fn from(r: pb::filter_to_search_in::rated::Rating) -> Self { +impl From for EaseKind { + fn from(r: pb::search_term::rated::Rating) -> Self { match r { - pb::filter_to_search_in::rated::Rating::AnswerButton1 => EaseKind::AnswerButton(1), - pb::filter_to_search_in::rated::Rating::AnswerButton2 => EaseKind::AnswerButton(2), - pb::filter_to_search_in::rated::Rating::AnswerButton3 => EaseKind::AnswerButton(3), - pb::filter_to_search_in::rated::Rating::AnswerButton4 => EaseKind::AnswerButton(4), - pb::filter_to_search_in::rated::Rating::AnyAnswerButton => EaseKind::AnyAnswerButton, - pb::filter_to_search_in::rated::Rating::ManualReschedule => EaseKind::ManualReschedule, + pb::search_term::rated::Rating::AnswerButton1 => EaseKind::AnswerButton(1), + pb::search_term::rated::Rating::AnswerButton2 => EaseKind::AnswerButton(2), + pb::search_term::rated::Rating::AnswerButton3 => EaseKind::AnswerButton(3), + pb::search_term::rated::Rating::AnswerButton4 => EaseKind::AnswerButton(4), + pb::search_term::rated::Rating::AnyAnswerButton => EaseKind::AnyAnswerButton, + pb::search_term::rated::Rating::ManualReschedule => EaseKind::ManualReschedule, } } } -impl From for StateKind { - fn from(k: pb::filter_to_search_in::CardState) -> Self { +impl From for StateKind { + fn from(k: pb::search_term::CardState) -> Self { match k { - pb::filter_to_search_in::CardState::New => StateKind::New, - pb::filter_to_search_in::CardState::Learn => StateKind::Learning, - pb::filter_to_search_in::CardState::Review => StateKind::Review, - pb::filter_to_search_in::CardState::Due => StateKind::Due, - pb::filter_to_search_in::CardState::Suspended => StateKind::Suspended, - pb::filter_to_search_in::CardState::Buried => StateKind::Buried, + pb::search_term::CardState::New => StateKind::New, + pb::search_term::CardState::Learn => StateKind::Learning, + pb::search_term::CardState::Review => StateKind::Review, + pb::search_term::CardState::Due => StateKind::Due, + pb::search_term::CardState::Suspended => StateKind::Suspended, + pb::search_term::CardState::Buried => StateKind::Buried, } } } @@ -502,7 +502,7 @@ impl BackendService for Backend { // searching //----------------------------------------------- - fn filter_to_search(&self, input: pb::FilterToSearchIn) -> Result { + fn filter_to_search(&self, input: pb::SearchTerm) -> Result { Ok(write_nodes(&[input.into()]).into()) }