diff --git a/crates/tabby-common/src/lib.rs b/crates/tabby-common/src/lib.rs index e999477a21ab..0c91be5b7cc1 100644 --- a/crates/tabby-common/src/lib.rs +++ b/crates/tabby-common/src/lib.rs @@ -39,7 +39,7 @@ impl SourceFile { } pub fn all() -> Result, Error> { - let files = glob::glob(&format!("{}*", Self::files_jsonl().display())).unwrap(); + let files = glob::glob(format!("{}*", Self::files_jsonl().display()).as_str()).unwrap(); let iter = files.filter_map(|x| x.ok()).flat_map(|path| { let fp = BufReader::new(File::open(path).unwrap()); let reader = JsonLinesReader::new(fp); diff --git a/ee/tabby-webserver/src/schema/repository.rs b/ee/tabby-webserver/src/schema/repository.rs index 36bc28c01aba..249b545d003d 100644 --- a/ee/tabby-webserver/src/schema/repository.rs +++ b/ee/tabby-webserver/src/schema/repository.rs @@ -1,9 +1,9 @@ -use std::ops::Range; + use async_trait::async_trait; use juniper::{GraphQLObject, ID}; use juniper_axum::relay::NodeType; -use tabby_common::SourceFile; + use validator::Validate; use super::{Context, Result}; @@ -34,98 +34,6 @@ pub struct FileEntry { pub path: String, } -#[derive(GraphQLObject)] -pub struct RepositoryMeta { - pub git_url: String, - pub filepath: String, - pub language: String, - pub max_line_length: i32, - pub avg_line_length: f64, - pub alphanum_fraction: f64, - pub tags: Vec, -} - -impl From for RepositoryMeta { - fn from(value: SourceFile) -> Self { - RepositoryMeta { - git_url: value.git_url, - filepath: value.filepath, - language: value.language, - max_line_length: value.max_line_length as i32, - avg_line_length: value.avg_line_length as f64, - alphanum_fraction: value.alphanum_fraction as f64, - tags: value - .tags - .into_iter() - .map(|tag| Tag { - range: tag.range.into(), - name_range: tag.name_range.into(), - utf16_column_range: tag.utf16_column_range.into(), - span: tag.span.into(), - line_range: tag.line_range.into(), - docs: tag.docs, - is_definition: tag.is_definition, - syntax_type_name: tag.syntax_type_name, - }) - .collect(), - } - } -} - -#[derive(GraphQLObject)] -pub struct Tag { - pub range: IntRange, - pub name_range: IntRange, - pub utf16_column_range: IntRange, - pub span: PointRange, - pub line_range: IntRange, - pub docs: Option, - pub is_definition: bool, - pub syntax_type_name: String, -} - -#[derive(GraphQLObject)] -pub struct Point { - pub row: i32, - pub col: i32, -} - -impl From> for PointRange { - fn from(value: Range) -> Self { - PointRange { - start: Point { - row: value.start.row as i32, - col: value.end.column as i32, - }, - end: Point { - row: value.end.row as i32, - col: value.end.column as i32, - }, - } - } -} - -#[derive(GraphQLObject)] -pub struct IntRange { - pub start: i32, - pub end: i32, -} - -impl From> for IntRange { - fn from(value: Range) -> Self { - IntRange { - start: value.start as i32, - end: value.end as i32, - } - } -} - -#[derive(GraphQLObject)] -pub struct PointRange { - pub start: Point, - pub end: Point, -} - impl NodeType for Repository { type Cursor = String;