mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Add cutoff_in_secs_from_days() helper method
This commit is contained in:
parent
5ec2e11de3
commit
699437df0f
1 changed files with 8 additions and 6 deletions
|
@ -479,23 +479,25 @@ impl SqlWriter<'_> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_added(&mut self, days: u32) -> Result<()> {
|
fn cutoff_in_secs_from_days(&mut self, days: u32) -> Result<i64> {
|
||||||
let timing = self.col.timing_today()?;
|
let timing = self.col.timing_today()?;
|
||||||
let cutoff = (timing.next_day_at.0 - (86_400 * (days as i64))) * 1_000;
|
Ok(timing.next_day_at.0 - (86_400 * (days as i64)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_added(&mut self, days: u32) -> Result<()> {
|
||||||
|
let cutoff = self.cutoff_in_secs_from_days(days)? * 1_000;
|
||||||
write!(self.sql, "c.id > {}", cutoff).unwrap();
|
write!(self.sql, "c.id > {}", cutoff).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_edited(&mut self, days: u32) -> Result<()> {
|
fn write_edited(&mut self, days: u32) -> Result<()> {
|
||||||
let timing = self.col.timing_today()?;
|
let cutoff = self.cutoff_in_secs_from_days(days)?;
|
||||||
let cutoff = timing.next_day_at.0 - (86_400 * (days as i64));
|
|
||||||
write!(self.sql, "n.mod > {}", cutoff).unwrap();
|
write!(self.sql, "n.mod > {}", cutoff).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_introduced(&mut self, days: u32) -> Result<()> {
|
fn write_introduced(&mut self, days: u32) -> Result<()> {
|
||||||
let timing = self.col.timing_today()?;
|
let cutoff = self.cutoff_in_secs_from_days(days)? * 1_000;
|
||||||
let cutoff = (timing.next_day_at.0 - (86_400 * (days as i64))) * 1_000;
|
|
||||||
write!(
|
write!(
|
||||||
self.sql,
|
self.sql,
|
||||||
"(select min(id) > {} from revlog where cid = c.id)",
|
"(select min(id) > {} from revlog where cid = c.id)",
|
||||||
|
|
Loading…
Reference in a new issue