diff --git a/rslib/backend.proto b/rslib/backend.proto index 62648e10f..899d74a0b 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -50,6 +50,10 @@ message NoteID { int64 nid = 1; } +message NoteIDs { + repeated int64 nids = 1; +} + message CardID { int64 cid = 1; } @@ -797,6 +801,7 @@ message FilterToSearchIn { uint32 added_in = 8; // will be due in the next x days int32 due_in = 9; + NoteIDs nids = 10; } } diff --git a/rslib/src/backend/mod.rs b/rslib/src/backend/mod.rs index 9cf765f8a..6d33d6df0 100644 --- a/rslib/src/backend/mod.rs +++ b/rslib/src/backend/mod.rs @@ -262,6 +262,12 @@ impl From for NoteID { } } +impl pb::NoteIDs { + fn into_id_string(self) -> String { + self.nids.iter().map(|i| i.to_string()).collect::>().join(",") + } +} + impl From for NoteTypeID { fn from(ntid: pb::NoteTypeId) -> Self { NoteTypeID(ntid.ntid) @@ -340,6 +346,7 @@ impl From for Node<'_> { operator: "<=".to_string(), kind: PropertyKind::Due(i), }), + Filter::Nids(nids) => Node::Search(SearchNode::NoteIDs(nids.into_id_string().into())), } } } diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index e9b6a377b..399ce177f 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -67,7 +67,7 @@ pub enum SearchNode<'a> { }, State(StateKind), Flag(u8), - NoteIDs(&'a str), + NoteIDs(Cow<'a, str>), CardIDs(&'a str), Property { operator: String, @@ -318,7 +318,7 @@ fn search_node_for_text_with_argument<'a>( "is" => parse_state(val)?, "did" => parse_did(val)?, "mid" => parse_mid(val)?, - "nid" => SearchNode::NoteIDs(check_id_list(val, key)?), + "nid" => SearchNode::NoteIDs(check_id_list(val, key)?.into()), "cid" => SearchNode::CardIDs(check_id_list(val, key)?), "re" => SearchNode::Regex(unescape_quotes(val)), "nc" => SearchNode::NoCombining(unescape(val)?),