Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Mar 29, 2024
1 parent a7a2862 commit 2841fd3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 28 deletions.
Binary file modified ee/tabby-db/schema.sqlite
Binary file not shown.
4 changes: 4 additions & 0 deletions ee/tabby-db/src/repositories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@ mod tests {
.unwrap()[0];
assert_eq!(repository.git_url, "testurl2");
assert_eq!(repository.name, "test2");
assert_eq!(
conn.get_repository_git_url("test2".into()).await.unwrap(),
repository.git_url
);
}
}
14 changes: 1 addition & 13 deletions ee/tabby-webserver/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use self::{
use crate::schema::{
auth::{JWTPayload, OAuthCredential, OAuthProvider},
job::JobStats,
repository::{FileEntry, RepositoryMeta},
repository::FileEntry,
};

pub trait ServiceLocator: Send + Sync {
Expand Down Expand Up @@ -309,18 +309,6 @@ impl Query {
.await?)
}

async fn repository_meta(
ctx: &Context,
repository: String,
path: String,
) -> FieldResult<RepositoryMeta> {
Ok(ctx
.locator
.repository()
.repository_meta(repository, path)
.await?)
}

async fn oauth_credential(
ctx: &Context,
provider: OAuthProvider,
Expand Down
1 change: 0 additions & 1 deletion ee/tabby-webserver/src/schema/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,4 @@ pub trait RepositoryService: Send + Sync {
path_glob: String,
top_n: usize,
) -> Result<Vec<FileEntry>>;
async fn repository_meta(&self, name: String, path: String) -> Result<RepositoryMeta>;
}
16 changes: 2 additions & 14 deletions ee/tabby-webserver/src/service/repository.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use std::path::Path;

use anyhow::anyhow;
use async_trait::async_trait;
use futures::StreamExt;
use juniper::ID;
use tabby_common::{config::RepositoryConfig, SourceFile};
use tabby_common::config::RepositoryConfig;
use tabby_db::DbConn;

use super::{graphql_pagination_to_filter, AsID, AsRowid};
use crate::schema::{
repository::{FileEntry, Repository, RepositoryMeta, RepositoryService},
repository::{FileEntry, Repository, RepositoryService},
Result,
};

Expand Down Expand Up @@ -101,17 +100,6 @@ impl RepositoryService for DbConn {
.map_err(anyhow::Error::from)?;
Ok(matching)
}

async fn repository_meta(&self, name: String, path: String) -> Result<RepositoryMeta> {
let git_url = self.get_repository_git_url(name).await?;
SourceFile::all()
.map_err(anyhow::Error::from)?
.filter_map(|file| {
(file.filepath == path && file.git_url == git_url).then(move || file.into())
})
.next()
.ok_or_else(|| anyhow!("File not found").into())
}
}

#[cfg(test)]
Expand Down

0 comments on commit 2841fd3

Please sign in to comment.