aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2021-05-30 01:19:14 +0200
committerTeddy Wing2021-05-30 01:19:14 +0200
commit37cbbc279736f10224ec36356eb2b7620b028081 (patch)
tree2f9bab187b855d1cb055cb655826512121bff4b7 /src
parent98cc67ceb69eea34e61ca08e51cd89a4bb483d66 (diff)
downloadreflectub-37cbbc279736f10224ec36356eb2b7620b028081.tar.bz2
database: Change `GithubRepo` arguments to `Repo`
Also change `repo_insert()` to take only a single repo instead of a slice of them.
Diffstat (limited to 'src')
-rw-r--r--src/database.rs28
1 files changed, 13 insertions, 15 deletions
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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
+ pub fn repo_update(repo: &Repo) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
}