mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Add nid filter on backend
This commit is contained in:
parent
1635f20af3
commit
bc52a54dfc
3 changed files with 14 additions and 2 deletions
|
@ -50,6 +50,10 @@ message NoteID {
|
||||||
int64 nid = 1;
|
int64 nid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message NoteIDs {
|
||||||
|
repeated int64 nids = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message CardID {
|
message CardID {
|
||||||
int64 cid = 1;
|
int64 cid = 1;
|
||||||
}
|
}
|
||||||
|
@ -797,6 +801,7 @@ message FilterToSearchIn {
|
||||||
uint32 added_in = 8;
|
uint32 added_in = 8;
|
||||||
// will be due in the next x days
|
// will be due in the next x days
|
||||||
int32 due_in = 9;
|
int32 due_in = 9;
|
||||||
|
NoteIDs nids = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,12 @@ impl From<pb::NoteId> for NoteID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl pb::NoteIDs {
|
||||||
|
fn into_id_string(self) -> String {
|
||||||
|
self.nids.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(",")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<pb::NoteTypeId> for NoteTypeID {
|
impl From<pb::NoteTypeId> for NoteTypeID {
|
||||||
fn from(ntid: pb::NoteTypeId) -> Self {
|
fn from(ntid: pb::NoteTypeId) -> Self {
|
||||||
NoteTypeID(ntid.ntid)
|
NoteTypeID(ntid.ntid)
|
||||||
|
@ -340,6 +346,7 @@ impl From<pb::FilterToSearchIn> for Node<'_> {
|
||||||
operator: "<=".to_string(),
|
operator: "<=".to_string(),
|
||||||
kind: PropertyKind::Due(i),
|
kind: PropertyKind::Due(i),
|
||||||
}),
|
}),
|
||||||
|
Filter::Nids(nids) => Node::Search(SearchNode::NoteIDs(nids.into_id_string().into())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub enum SearchNode<'a> {
|
||||||
},
|
},
|
||||||
State(StateKind),
|
State(StateKind),
|
||||||
Flag(u8),
|
Flag(u8),
|
||||||
NoteIDs(&'a str),
|
NoteIDs(Cow<'a, str>),
|
||||||
CardIDs(&'a str),
|
CardIDs(&'a str),
|
||||||
Property {
|
Property {
|
||||||
operator: String,
|
operator: String,
|
||||||
|
@ -318,7 +318,7 @@ fn search_node_for_text_with_argument<'a>(
|
||||||
"is" => parse_state(val)?,
|
"is" => parse_state(val)?,
|
||||||
"did" => parse_did(val)?,
|
"did" => parse_did(val)?,
|
||||||
"mid" => parse_mid(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)?),
|
"cid" => SearchNode::CardIDs(check_id_list(val, key)?),
|
||||||
"re" => SearchNode::Regex(unescape_quotes(val)),
|
"re" => SearchNode::Regex(unescape_quotes(val)),
|
||||||
"nc" => SearchNode::NoCombining(unescape(val)?),
|
"nc" => SearchNode::NoCombining(unescape(val)?),
|
||||||
|
|
Loading…
Reference in a new issue