diff options
author | Jesse Luehrs <doy@tozt.net> | 2018-11-06 22:16:51 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2018-11-06 22:16:51 -0500 |
commit | a47cdb90b8bfb91bccb7ea7d36a54115d429605d (patch) | |
tree | 51ce776d43673782c4f7e6cfa1b54c99db5e3f3c | |
parent | eefaa5da49f0cee473b10899d8fb2064f85c3eff (diff) | |
download | lastfm-query-a47cdb90b8bfb91bccb7ea7d36a54115d429605d.tar.gz lastfm-query-a47cdb90b8bfb91bccb7ea7d36a54115d429605d.zip |
method to see when the most recent track we know about happened
-rw-r--r-- | src/db.rs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -43,4 +43,17 @@ impl DB { unimplemented!(); } } + + pub fn most_recent_timestamp(&self) -> Result<Option<i64>> { + 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), + } + })?) + } } |