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 4 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
Binary file modified ee/tabby-db/schema.sqlite
boxbeam marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
13 changes: 12 additions & 1 deletion 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};
use sqlx::{prelude::FromRow, query, query_scalar};

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

Expand Down Expand Up @@ -64,6 +64,13 @@ impl DbConn {
Err(anyhow!("failed to update: repository not found"))
}
}

pub async fn get_repository_git_url(&self, name: String) -> Result<String> {
boxbeam marked this conversation as resolved.
Show resolved Hide resolved
boxbeam marked this conversation as resolved.
Show resolved Hide resolved
let url = query_scalar!("SELECT git_url FROM repositories WHERE name = ?", name)
.fetch_one(&self.pool)
.await?;
Ok(url)
}
}

#[cfg(test)]
Expand Down Expand Up @@ -99,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
);
}
}
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