From 947260e4aaebf77dcaf40b09b501a0828c8f7e8e Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 16 Jan 2021 17:38:02 +0100 Subject: [PATCH] Reintroduce false removed limits --- rslib/src/search/parser.rs | 5 +++-- rslib/src/search/sqlwriter.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index f0091e80b..59710b5a9 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -406,7 +406,7 @@ fn parse_prop(s: &str) -> ParseResult { let mut it = num.splitn(2, ':'); let days: i32 = if let Ok(i) = it.next().unwrap().parse::() { - i + i.min(0) } else { return Err(parse_failure( s, @@ -438,7 +438,7 @@ fn parse_prop(s: &str) -> ParseResult { PropertyKind::Rated(days, ease) } else if prop == "resched" { if let Ok(days) = num.parse::() { - 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 { fn parse_rated(s: &str) -> ParseResult { let mut it = s.splitn(2, ':'); if let Ok(days) = it.next().unwrap().parse::() { + let days = days.max(1); let ease = if let Some(tail) = it.next() { if let Ok(u) = tail.parse::() { if u > 0 && u < 5 { diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index 9b0fe3205..7a359333a 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -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!(