wire reminder ops into the in-agent socket dispatch (#2635 inc 1)
This commit is contained in:
parent
174e277340
commit
ecd9030305
6 changed files with 178 additions and 45 deletions
|
|
@ -43,6 +43,7 @@ pub struct Reminder {
|
|||
pub message: String,
|
||||
pub file_path: Option<String>,
|
||||
pub due_at: i64,
|
||||
pub created_at: i64,
|
||||
}
|
||||
|
||||
/// The harness-local reminder store. Cheap to share behind an `Arc`; the
|
||||
|
|
@ -121,7 +122,7 @@ impl Reminders {
|
|||
pub fn list_pending(&self) -> Result<Vec<Reminder>> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT id, message, file_path, due_at \
|
||||
"SELECT id, message, file_path, due_at, created_at \
|
||||
FROM reminders WHERE sent_at IS NULL ORDER BY due_at ASC",
|
||||
)?;
|
||||
let rows = stmt
|
||||
|
|
@ -143,7 +144,7 @@ impl Reminders {
|
|||
pub fn due(&self, now: i64, limit: u64) -> Result<Vec<Reminder>> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT id, message, file_path, due_at \
|
||||
"SELECT id, message, file_path, due_at, created_at \
|
||||
FROM reminders WHERE sent_at IS NULL AND due_at <= ?1 \
|
||||
ORDER BY due_at ASC LIMIT ?2",
|
||||
)?;
|
||||
|
|
@ -262,6 +263,7 @@ fn row_to_reminder(row: &rusqlite::Row) -> rusqlite::Result<Reminder> {
|
|||
message: row.get(1)?,
|
||||
file_path: row.get(2)?,
|
||||
due_at: row.get(3)?,
|
||||
created_at: row.get(4)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +353,9 @@ mod tests {
|
|||
assert_eq!(n, 1, "only the backdated row is older than cutoff");
|
||||
let remaining_ids: Vec<i64> = {
|
||||
let conn = s.conn.lock().unwrap();
|
||||
let mut stmt = conn.prepare("SELECT id FROM reminders ORDER BY id").unwrap();
|
||||
let mut stmt = conn
|
||||
.prepare("SELECT id FROM reminders ORDER BY id")
|
||||
.unwrap();
|
||||
stmt.query_map([], |row| row.get(0))
|
||||
.unwrap()
|
||||
.collect::<rusqlite::Result<Vec<_>>>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue