diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index 1dc64f1a8..8fe5412f5 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -60,6 +60,7 @@ pub(super) enum SearchNode<'a> { is_re: bool, }, AddedInDays(u32), + EditedInDays(u32), CardTemplate(TemplateKind), Deck(Cow<'a, str>), NoteTypeID(NoteTypeID), @@ -269,6 +270,7 @@ fn search_node_for_text_with_argument<'a>( ) -> ParseResult> { Ok(match key.to_ascii_lowercase().as_str() { "added" => SearchNode::AddedInDays(val.parse()?), + "edited" => SearchNode::EditedInDays(val.parse()?), "deck" => SearchNode::Deck(val), "note" => SearchNode::NoteType(val), "tag" => SearchNode::Tag(val), diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index c287bc6d7..06b726b25 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -129,6 +129,7 @@ impl SqlWriter<'_> { // other SearchNode::AddedInDays(days) => self.write_added(*days)?, + SearchNode::EditedInDays(days) => self.write_edited(*days)?, SearchNode::CardTemplate(template) => match template { TemplateKind::Ordinal(_) => { self.write_template(template)?; @@ -424,6 +425,13 @@ impl SqlWriter<'_> { Ok(()) } + fn write_edited(&mut self, days: u32) -> Result<()> { + let timing = self.col.timing_today()?; + let cutoff = timing.next_day_at - (86_400 * (days as i64)); + write!(self.sql, "n.mod > {}", cutoff).unwrap(); + Ok(()) + } + fn write_regex(&mut self, word: &str) { self.sql.push_str("n.flds regexp ?"); self.args.push(format!(r"(?i){}", word)); @@ -537,6 +545,7 @@ impl SearchNode<'_> { SearchNode::WordBoundary(_) => RequiredTable::Notes, SearchNode::NoteTypeID(_) => RequiredTable::Notes, SearchNode::NoteType(_) => RequiredTable::Notes, + SearchNode::EditedInDays(_) => RequiredTable::Notes, SearchNode::NoteIDs(_) => RequiredTable::CardsOrNotes, SearchNode::WholeCollection => RequiredTable::CardsOrNotes,