Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Apr 4, 2024
1 parent 6e706d7 commit b2012a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 95 deletions.
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 @@ impl SourceFile {
}

pub fn all() -> Result<impl Iterator<Item = Self>, 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);
Expand Down
96 changes: 2 additions & 94 deletions ee/tabby-webserver/src/schema/repository.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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<Tag>,
}

impl From<SourceFile> 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<String>,
pub is_definition: bool,
pub syntax_type_name: String,
}

#[derive(GraphQLObject)]
pub struct Point {
pub row: i32,
pub col: i32,
}

impl From<Range<tabby_common::Point>> for PointRange {
fn from(value: Range<tabby_common::Point>) -> 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<Range<usize>> for IntRange {
fn from(value: Range<usize>) -> 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;

Expand Down

0 comments on commit b2012a1

Please sign in to comment.