Reintroduce false removed limits

This commit is contained in:
Henrik Giesel 2021-01-16 17:38:02 +01:00
parent e7660113ce
commit 947260e4aa
2 changed files with 6 additions and 4 deletions

View File

@ -406,7 +406,7 @@ fn parse_prop(s: &str) -> ParseResult<SearchNode> {
let mut it = num.splitn(2, ':');
let days: i32 = if let Ok(i) = it.next().unwrap().parse::<i32>() {
i
i.min(0)
} else {
return Err(parse_failure(
s,
@ -438,7 +438,7 @@ fn parse_prop(s: &str) -> ParseResult<SearchNode> {
PropertyKind::Rated(days, ease)
} else if prop == "resched" {
if let Ok(days) = num.parse::<i32>() {
PropertyKind::Rated(days, EaseKind::ManualReschedule)
PropertyKind::Rated(days.min(0), EaseKind::ManualReschedule)
} else {
return Err(parse_failure(
s,
@ -489,6 +489,7 @@ fn parse_edited(s: &str) -> ParseResult<SearchNode> {
fn parse_rated(s: &str) -> ParseResult<SearchNode> {
let mut it = s.splitn(2, ':');
if let Ok(days) = it.next().unwrap().parse::<u32>() {
let days = days.max(1);
let ease = if let Some(tail) = it.next() {
if let Ok(u) = tail.parse::<u8>() {
if u > 0 && u < 5 {

View File

@ -734,7 +734,7 @@ mod test {
s(ctx, "rated:400:1").0,
format!(
"(c.id in (select cid from revlog where id >= {} and ease = 1))",
(timing.next_day_at - (86_400 * 365)) * 1_000
(timing.next_day_at - (86_400 * 400)) * 1_000
)
);
assert_eq!(s(ctx, "rated:0").0, s(ctx, "rated:1").0);
@ -744,7 +744,7 @@ mod test {
s(ctx, "resched:400").0,
format!(
"(c.id in (select cid from revlog where id >= {} and ease = 0))",
(timing.next_day_at - (86_400 * 365)) * 1_000
(timing.next_day_at - (86_400 * 400)) * 1_000
)
);
@ -759,6 +759,7 @@ mod test {
cutoff = timing.next_day_at
)
);
assert_eq!(s(ctx, "prop:rated>-5:3").0, s(ctx, "rated:5:3").0);
// note types by name
assert_eq!(