From a47cdb90b8bfb91bccb7ea7d36a54115d429605d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 6 Nov 2018 22:16:51 -0500 Subject: method to see when the most recent track we know about happened --- src/db.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/db.rs b/src/db.rs index e9e2c62..450202f 100644 --- a/src/db.rs +++ b/src/db.rs @@ -43,4 +43,17 @@ impl DB { unimplemented!(); } } + + pub fn most_recent_timestamp(&self) -> Result> { + Ok(self.conn.query_row( + "SELECT timestamp FROM tracks ORDER BY timestamp DESC LIMIT 1", + rusqlite::NO_PARAMS, + |row| Some(row.get(0)) + ).or_else(|e| { + match e { + rusqlite::Error::QueryReturnedNoRows => Ok(None), + _ => Err(e), + } + })?) + } } -- cgit v1.2.3