From 37cbbc279736f10224ec36356eb2b7620b028081 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 30 May 2021 01:19:14 +0200 Subject: database: Change `GithubRepo` arguments to `Repo` Also change `repo_insert()` to take only a single repo instead of a slice of them. --- src/database.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/database.rs b/src/database.rs index 4c14f2e..83a27b3 100644 --- a/src/database.rs +++ b/src/database.rs @@ -77,23 +77,21 @@ impl Db { pub async fn repo_insert( &mut self, - repos: &[GithubRepo], + repo: Repo, ) -> Result<(), Box> { let mut tx = self.connection.begin().await?; - for repo in repos { - sqlx::query(r#" - INSERT INTO repositories - (id, name, updated_at) - VALUES - (?, ?, ?) - "#) - .bind(repo.id) - .bind(&repo.name) - .bind(&repo.updated_at) - .execute(&mut tx) - .await?; - } + sqlx::query(r#" + INSERT INTO repositories + (id, name, updated_at) + VALUES + (?, ?, ?) + "#) + .bind(repo.id) + .bind(&repo.name) + .bind(&repo.updated_at) + .execute(&mut tx) + .await?; tx.commit().await?; @@ -105,7 +103,7 @@ impl Db { Ok(false) } - pub fn repo_update(repo: &GithubRepo) -> Result<(), Box> { + pub fn repo_update(repo: &Repo) -> Result<(), Box> { Ok(()) } } -- cgit v1.2.3