Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Apr 1, 2024
1 parent b17b4fc commit 2361640
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions ee/tabby-db/migrations/0021_repository-name-index.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX idx_repository_name;
1 change: 1 addition & 0 deletions ee/tabby-db/migrations/0021_repository-name-index.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- Add up migration script here
Binary file modified ee/tabby-db/schema.sqlite
Binary file not shown.
19 changes: 12 additions & 7 deletions ee/tabby-db/src/repositories.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use sqlx::{prelude::FromRow, query, query_scalar};
use sqlx::{prelude::FromRow, query};

use crate::{make_pagination_query, DbConn, SQLXResultExt};

Expand Down Expand Up @@ -65,11 +65,13 @@ impl DbConn {
}
}

pub async fn get_repository_git_url(&self, name: String) -> Result<String> {
let url = query_scalar!("SELECT git_url FROM repositories WHERE name = ?", name)
.fetch_one(&self.pool)
.await?;
Ok(url)
pub async fn get_repository_by_name(&self, name: String) -> Result<RepositoryDAO> {
let repository =
sqlx::query_as("SELECT id, name, git_url FROM repositories WHERE name = ?;")
.bind(name)
.fetch_one(&self.pool)
.await?;
Ok(repository)
}
}

Expand Down Expand Up @@ -107,7 +109,10 @@ mod tests {
assert_eq!(repository.git_url, "testurl2");
assert_eq!(repository.name, "test2");
assert_eq!(
conn.get_repository_git_url("test2".into()).await.unwrap(),
conn.get_repository_by_name("test2".into())
.await
.unwrap()
.git_url,
repository.git_url
);
}
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-webserver/src/service/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl RepositoryService for DbConn {
if path_glob.trim().is_empty() {
return Ok(vec![]);
}
let git_url = self.get_repository_git_url(name.clone()).await?;
let git_url = self.get_repository_by_name(name.clone()).await?.git_url;
let config = RepositoryConfig::new_named(name, git_url);
let matching = find_glob(&config.dir(), &path_glob, top_n)
.await
Expand Down

0 comments on commit 2361640

Please sign in to comment.