Support prop:order to search for new cards by order

This commit is contained in:
abdo 2021-01-01 03:34:25 +03:00
parent eecdc07c68
commit 0ad4619833
2 changed files with 12 additions and 0 deletions

View file

@ -97,6 +97,7 @@ pub(super) enum PropertyKind {
Reps(u32), Reps(u32),
Lapses(u32), Lapses(u32),
Ease(f32), Ease(f32),
Order(u32),
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -373,6 +374,7 @@ fn parse_prop(val: &str) -> ParseResult<SearchNode<'static>> {
tag("reps"), tag("reps"),
tag("lapses"), tag("lapses"),
tag("ease"), tag("ease"),
tag("order"),
))(val)?; ))(val)?;
let (val, operator) = alt(( let (val, operator) = alt((
@ -396,6 +398,7 @@ fn parse_prop(val: &str) -> ParseResult<SearchNode<'static>> {
"ivl" => PropertyKind::Interval(num), "ivl" => PropertyKind::Interval(num),
"reps" => PropertyKind::Reps(num), "reps" => PropertyKind::Reps(num),
"lapses" => PropertyKind::Lapses(num), "lapses" => PropertyKind::Lapses(num),
"order" => PropertyKind::Order(num),
_ => unreachable!(), _ => unreachable!(),
} }
}; };

View file

@ -247,6 +247,15 @@ impl SqlWriter<'_> {
day = day day = day
) )
} }
PropertyKind::Order(order) => {
write!(
self.sql,
"(c.type = {t} and due {op} {order})",
t = CardType::New as u8,
op = op,
order = order
)
}
PropertyKind::Interval(ivl) => write!(self.sql, "ivl {} {}", op, ivl), PropertyKind::Interval(ivl) => write!(self.sql, "ivl {} {}", op, ivl),
PropertyKind::Reps(reps) => write!(self.sql, "reps {} {}", op, reps), PropertyKind::Reps(reps) => write!(self.sql, "reps {} {}", op, reps),
PropertyKind::Lapses(days) => write!(self.sql, "lapses {} {}", op, days), PropertyKind::Lapses(days) => write!(self.sql, "lapses {} {}", op, days),