mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
fix added
This commit is contained in:
parent
5df04b161c
commit
2693e142aa
1 changed files with 15 additions and 3 deletions
|
@ -58,9 +58,7 @@ impl SqlWriter<'_, '_> {
|
|||
SearchNode::SingleField { field, text } => {
|
||||
self.write_single_field(field.as_ref(), text.as_ref())?
|
||||
}
|
||||
SearchNode::AddedInDays(days) => {
|
||||
write!(self.sql, "c.id > {}", days).unwrap();
|
||||
}
|
||||
SearchNode::AddedInDays(days) => self.write_added(*days)?,
|
||||
SearchNode::CardTemplate(template) => self.write_template(template)?,
|
||||
SearchNode::Deck(deck) => self.write_deck(deck.as_ref())?,
|
||||
SearchNode::NoteTypeID(ntid) => {
|
||||
|
@ -306,6 +304,13 @@ impl SqlWriter<'_, '_> {
|
|||
.unwrap();
|
||||
self.args.push(text.to_string().into())
|
||||
}
|
||||
|
||||
fn write_added(&mut self, days: u32) -> Result<()> {
|
||||
let timing = self.req.storage.timing_today()?;
|
||||
let cutoff = timing.next_day_at - (86_400 * (days as i64));
|
||||
write!(self.sql, "c.id > {}", cutoff).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Write a list of IDs as '(x,y,...)' into the provided string.
|
||||
|
@ -403,6 +408,13 @@ mod test {
|
|||
)
|
||||
);
|
||||
|
||||
// added
|
||||
let t = ctx.storage.timing_today().unwrap();
|
||||
assert_eq!(
|
||||
s(ctx, "added:3").0,
|
||||
format!("(c.id > {})", t.next_day_at - (86_400 * 3))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in a new issue