Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webserver): Implement file search and meta query #1731

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 168 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tabby-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

pub fn all() -> Result<impl Iterator<Item = Self>, Error> {
let files = glob::glob(format!("{}*", Self::files_jsonl().display()).as_str()).unwrap();
let files = glob::glob(&format!("{}*", Self::files_jsonl().display())).unwrap();

Check warning on line 42 in crates/tabby-common/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-common/src/lib.rs#L42

Added line #L42 was not covered by tests
let iter = files.filter_map(|x| x.ok()).flat_map(|path| {
let fp = BufReader::new(File::open(path).unwrap());
let reader = JsonLinesReader::new(fp);
Expand Down
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 @@
CREATE INDEX idx_repository_name ON repositories(name);
Binary file modified ee/tabby-db/schema.sqlite
Binary file not shown.
16 changes: 16 additions & 0 deletions ee/tabby-db/src/repositories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ impl DbConn {
Err(anyhow!("failed to update: repository not found"))
}
}

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)
}
}

#[cfg(test)]
Expand Down Expand Up @@ -99,5 +108,12 @@ mod tests {
.unwrap()[0];
assert_eq!(repository.git_url, "testurl2");
assert_eq!(repository.name, "test2");
assert_eq!(
conn.get_repository_by_name("test2".into())
.await
.unwrap()
.git_url,
repository.git_url
);
}
}
1 change: 1 addition & 0 deletions ee/tabby-webserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ prod-db = ['tabby-db/prod-db']
anyhow.workspace = true
argon2 = "0.5.1"
async-trait.workspace = true
async-walkdir = "1.0.0"
axum = { workspace = true, features = ["ws", "headers"] }
base64 = "0.22.0"
bincode = "1.3.3"
Expand Down
6 changes: 6 additions & 0 deletions ee/tabby-webserver/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ enum WorkerKind {
CHAT
}

type FileEntry {
type: String!
path: String!
}

type Mutation {
resetRegistrationToken: String!
requestInvitationEmail(input: RequestInvitationInput!): Invitation!
Expand Down Expand Up @@ -81,6 +86,7 @@ type Query {
networkSetting: NetworkSetting!
securitySetting: SecuritySetting!
repositories(after: String, before: String, first: Int, last: Int): RepositoryConnection!
repositorySearch(repository: String!, filter: String!): [FileEntry!]!
oauthCredential(provider: OAuthProvider!): OAuthCredential
oauthCallbackUrl(provider: OAuthProvider!): String!
serverInfo: ServerInfo!
Expand Down
Loading
Loading