summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-11-06 22:16:51 -0500
committerJesse Luehrs <doy@tozt.net>2018-11-06 22:16:51 -0500
commita47cdb90b8bfb91bccb7ea7d36a54115d429605d (patch)
tree51ce776d43673782c4f7e6cfa1b54c99db5e3f3c
parenteefaa5da49f0cee473b10899d8fb2064f85c3eff (diff)
downloadlastfm-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.rs13
1 files changed, 13 insertions, 0 deletions
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<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),
+ }
+ })?)
+ }
}