aboutsummaryrefslogtreecommitdiffstats
path: root/src/database.rs
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 03:37:16 +0200
committerTeddy Wing2021-05-30 03:38:46 +0200
commit4d4b7918726b4a56b87de8cdc577b6bf088c5f91 (patch)
tree1d8a71ecd64cf6f2b42c57db37b6d7d3c97b3955 /src/database.rs
parenta879ee3ff4b73a013eb9303e5790c2a9df0a4f5b (diff)
downloadreflectub-4d4b7918726b4a56b87de8cdc577b6bf088c5f91.tar.bz2
main: If repo was updated, save new `updated_at` value
If the repo was updated since we last cached it, update the `updated_at` column to the new value so we know that we fetched the latest.
Diffstat (limited to 'src/database.rs')
-rw-r--r--src/database.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/database.rs b/src/database.rs
index e735df9..2a53f0b 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -139,7 +139,21 @@ impl Db {
is_updated
}
- pub fn repo_update(repo: &Repo) -> Result<(), Error> {
+ pub async fn repo_update(&mut self, repo: &Repo) -> Result<(), Error> {
+ let mut tx = self.connection.begin().await?;
+
+ sqlx::query(r#"
+ UPDATE repositories
+ SET updated_at = ?
+ WHERE id = ?
+ "#)
+ .bind(&repo.updated_at)
+ .bind(repo.id)
+ .execute(&mut tx)
+ .await?;
+
+ tx.commit().await?;
+
Ok(())
}
}