Skip to content

Commit

Permalink
restructure dir for repository
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Apr 26, 2024
1 parent 59e8b0e commit 7c800ed
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 61 deletions.
2 changes: 1 addition & 1 deletion ee/tabby-webserver/src/cron/db/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use juniper::ID;
use octocrab::{models::Repository, GitHubError, Octocrab};
use tracing::warn;

use crate::schema::github_repository::{GithubRepositoryProvider, GithubRepositoryService};
use crate::schema::repository::{GithubRepositoryProvider, GithubRepositoryService};

pub async fn refresh_all_repositories(service: Arc<dyn GithubRepositoryService>) -> Result<()> {

Check warning on line 11 in ee/tabby-webserver/src/cron/db/github.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/cron/db/github.rs#L11

Added line #L11 was not covered by tests
for provider in service
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-webserver/src/cron/db/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use juniper::ID;
use serde::Deserialize;
use tracing::warn;

use crate::schema::gitlab_repository::{GitlabRepositoryProvider, GitlabRepositoryService};
use crate::schema::repository::{GitlabRepositoryProvider, GitlabRepositoryService};

pub async fn refresh_all_repositories(service: Arc<dyn GitlabRepositoryService>) -> Result<()> {

Check warning on line 15 in ee/tabby-webserver/src/cron/db/gitlab.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/cron/db/gitlab.rs#L15

Added line #L15 was not covered by tests
for provider in service
Expand Down
5 changes: 3 additions & 2 deletions ee/tabby-webserver/src/cron/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use tokio_cron_scheduler::Job;
use tracing::{debug, error};

use crate::schema::{
auth::AuthenticationService, github_repository::GithubRepositoryService,
gitlab_repository::GitlabRepositoryService, job::JobService,
auth::AuthenticationService,
job::JobService,
repository::{GithubRepositoryService, GitlabRepositoryService},
};

const EVERY_TWO_HOURS: &str = "0 0 1/2 * * * *";
Expand Down
28 changes: 10 additions & 18 deletions ee/tabby-webserver/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ pub mod analytic;
pub mod auth;
pub mod constants;
pub mod email;
pub mod git_repository;
pub mod github_repository;
pub mod gitlab_repository;
pub mod job;
pub mod license;
pub mod repository;
pub mod setting;
pub mod types;
pub mod user_event;
pub mod worker;

Expand Down Expand Up @@ -38,16 +34,12 @@ use self::{
RequestInvitationInput, RequestPasswordResetEmailInput, UpdateOAuthCredentialInput,
},
email::{EmailService, EmailSetting, EmailSettingInput},
git_repository::GitRepository,
github_repository::{GithubProvidedRepository, GithubRepositoryProvider},
gitlab_repository::{GitlabProvidedRepository, GitlabRepositoryProvider},
job::JobStats,
license::{IsLicenseValid, LicenseInfo, LicenseService, LicenseType},
repository::{FileEntrySearchResult, Repository, RepositoryKind, RepositoryService},
setting::{
NetworkSetting, NetworkSettingInput, SecuritySetting, SecuritySettingInput, SettingService,
},
types::{CreateRepositoryProviderInput, UpdateRepositoryProviderInput},
user_event::{UserEvent, UserEventService},
};
use crate::{
Expand Down Expand Up @@ -230,7 +222,7 @@ impl Query {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<Connection<GithubRepositoryProvider>> {
) -> Result<Connection<repository::GithubRepositoryProvider>> {
check_admin(ctx).await?;
relay::query_async(
after,
Expand All @@ -255,7 +247,7 @@ impl Query {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<Connection<GithubProvidedRepository>> {
) -> Result<Connection<repository::GithubProvidedRepository>> {
check_admin(ctx).await?;
relay::query_async(
after,
Expand All @@ -280,7 +272,7 @@ impl Query {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<Connection<GitlabRepositoryProvider>> {
) -> Result<Connection<repository::GitlabRepositoryProvider>> {
check_admin(ctx).await?;
relay::query_async(
after,
Expand All @@ -305,7 +297,7 @@ impl Query {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<Connection<GitlabProvidedRepository>> {
) -> Result<Connection<repository::GitlabProvidedRepository>> {
check_admin(ctx).await?;
relay::query_async(
after,
Expand Down Expand Up @@ -374,7 +366,7 @@ impl Query {
before: Option<String>,
first: Option<i32>,
last: Option<i32>,
) -> Result<Connection<GitRepository>> {
) -> Result<Connection<repository::GitRepository>> {
check_admin(ctx).await?;
relay::query_async(
after,
Expand Down Expand Up @@ -682,7 +674,7 @@ impl Mutation {

async fn create_git_repository(ctx: &Context, name: String, git_url: String) -> Result<ID> {
check_admin(ctx).await?;
let input = git_repository::CreateGitRepositoryInput { name, git_url };
let input = repository::CreateGitRepositoryInput { name, git_url };
input.validate()?;
ctx.locator
.repository()
Expand Down Expand Up @@ -774,7 +766,7 @@ impl Mutation {

async fn create_github_repository_provider(
ctx: &Context,
input: CreateRepositoryProviderInput,
input: repository::CreateRepositoryProviderInput,
) -> Result<ID> {
check_admin(ctx).await?;
input.validate()?;
Expand All @@ -799,7 +791,7 @@ impl Mutation {

async fn update_github_repository_provider(
ctx: &Context,
input: UpdateRepositoryProviderInput,
input: repository::UpdateRepositoryProviderInput,
) -> Result<bool> {
check_admin(ctx).await?;
input.validate()?;
Expand All @@ -826,7 +818,7 @@ impl Mutation {

async fn create_gitlab_repository_provider(
ctx: &Context,
input: CreateRepositoryProviderInput,
input: repository::CreateRepositoryProviderInput,
) -> Result<ID> {
check_admin(ctx).await?;
input.validate()?;
Expand All @@ -851,7 +843,7 @@ impl Mutation {

async fn update_gitlab_repository_provider(
ctx: &Context,
input: UpdateRepositoryProviderInput,
input: repository::UpdateRepositoryProviderInput,
) -> Result<bool> {
check_admin(ctx).await?;
input.validate()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use async_trait::async_trait;
use juniper::{GraphQLObject, ID};
use validator::Validate;

use super::{repository::RepositoryProvider, Context, Result};
use crate::juniper::relay::NodeType;
use super::RepositoryProvider;
use crate::{
juniper::relay::NodeType,
schema::{Context, Result},
};

#[derive(Validate)]
pub struct CreateGitRepositoryInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use async_trait::async_trait;
use chrono::{DateTime, Utc};
use juniper::{GraphQLObject, ID};

use super::{repository::RepositoryProvider, types::RepositoryProviderStatus, Context};
use crate::{juniper::relay::NodeType, schema::Result};
use super::{RepositoryProvider, RepositoryProviderStatus};
use crate::{
juniper::relay::NodeType,
schema::{Context, Result},
};

#[derive(GraphQLObject, Debug, PartialEq)]
#[graphql(context = Context)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use async_trait::async_trait;
use chrono::{DateTime, Utc};
use juniper::{GraphQLObject, ID};

use super::{repository::RepositoryProvider, types::RepositoryProviderStatus, Context};
use crate::{juniper::relay::NodeType, schema::Result};
use super::{RepositoryProvider, RepositoryProviderStatus};
use crate::{
juniper::relay::NodeType,
schema::{Context, Result},
};

#[derive(GraphQLObject, Debug, PartialEq)]
#[graphql(context = Context)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
mod types;
pub use types::*;

mod git_repository;
pub use git_repository::{CreateGitRepositoryInput, GitRepository, GitRepositoryService};

mod github_repository;
pub use github_repository::{
GithubProvidedRepository, GithubRepositoryProvider, GithubRepositoryService,
};

mod gitlab_repository;
use std::{path::PathBuf, sync::Arc};

use async_trait::async_trait;
pub use gitlab_repository::{
GitlabProvidedRepository, GitlabRepositoryProvider, GitlabRepositoryService,
};
use juniper::{GraphQLEnum, GraphQLObject, ID};
use serde::Deserialize;
use tabby_common::config::{RepositoryAccess, RepositoryConfig};
use tabby_search::FileSearch;

use super::{
git_repository::{GitRepository, GitRepositoryService},
github_repository::{GithubProvidedRepository, GithubRepositoryService},
gitlab_repository::{GitlabProvidedRepository, GitlabRepositoryService},
Result,
};
use super::Result;

#[derive(GraphQLObject, Debug)]
pub struct FileEntrySearchResult {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions ee/tabby-webserver/src/service/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use crate::{
schema::{
auth::{self, OAuthCredential, OAuthProvider},
email::{AuthMethod, EmailSetting, Encryption},
git_repository::GitRepository,
github_repository::{GithubProvidedRepository, GithubRepositoryProvider},
gitlab_repository::{GitlabProvidedRepository, GitlabRepositoryProvider},
job,
repository::{
GitRepository, GithubProvidedRepository, GithubRepositoryProvider,
GitlabProvidedRepository, GitlabRepositoryProvider, RepositoryProviderStatus,
},
setting::{NetworkSetting, SecuritySetting},
types::RepositoryProviderStatus,
user_event::{EventKind, UserEvent},
CoreError,
},
Expand Down
3 changes: 0 additions & 3 deletions ee/tabby-webserver/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ mod auth;
mod dao;
mod email;
pub mod event_logger;
mod git_repository;
mod github_repository;
mod gitlab_repository;
mod job;
mod license;
mod proxy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ use async_trait::async_trait;
use juniper::ID;
use tabby_db::DbConn;

use super::{graphql_pagination_to_filter, AsID, AsRowid};
use crate::schema::{
git_repository::{GitRepository, GitRepositoryService},
repository::{Repository, RepositoryProvider},
Result,
use crate::{
schema::{
repository::{GitRepository, GitRepositoryService, Repository, RepositoryProvider},
Result,
},
service::{graphql_pagination_to_filter, AsID, AsRowid},
};

#[async_trait]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ use juniper::ID;
use tabby_db::DbConn;
use url::Url;

use super::{AsID, AsRowid};
use crate::{
schema::{
github_repository::{
repository::{
GithubProvidedRepository, GithubRepositoryProvider, GithubRepositoryService,
Repository, RepositoryProvider,
},
repository::{Repository, RepositoryProvider},
Result,
},
service::graphql_pagination_to_filter,
service::{graphql_pagination_to_filter, AsID, AsRowid},
};

struct GithubRepositoryProviderServiceImpl {
Expand Down Expand Up @@ -216,7 +215,7 @@ mod tests {
use chrono::Duration;

use super::*;
use crate::{schema::types::RepositoryProviderStatus, service::AsID};
use crate::{schema::repository::RepositoryProviderStatus, service::AsID};

#[tokio::test]
async fn test_github_provided_repositories() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ use juniper::ID;
use tabby_db::DbConn;
use url::Url;

use super::{AsID, AsRowid};
use crate::{
schema::{
gitlab_repository::{
repository::{
GitlabProvidedRepository, GitlabRepositoryProvider, GitlabRepositoryService,
Repository, RepositoryProvider,
},
repository::{Repository, RepositoryProvider},
Result,
},
service::graphql_pagination_to_filter,
service::{graphql_pagination_to_filter, AsID, AsRowid},
};

struct GitlabRepositoryProviderServiceImpl {
Expand Down Expand Up @@ -219,7 +218,7 @@ mod tests {
use chrono::Duration;

use super::*;
use crate::{schema::types::RepositoryProviderStatus, service::AsID};
use crate::{schema::repository::RepositoryProviderStatus, service::AsID};

#[tokio::test]
async fn test_gitlab_provided_repositories() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
mod git_repository;
mod github_repository;
mod gitlab_repository;

use std::sync::Arc;

use async_trait::async_trait;
use juniper::ID;
use tabby_common::config::{RepositoryAccess, RepositoryConfig};
use tabby_db::DbConn;

use super::{github_repository, gitlab_repository, Result};
use crate::schema::{
git_repository::GitRepositoryService,
github_repository::GithubRepositoryService,
gitlab_repository::GitlabRepositoryService,
repository::{FileEntrySearchResult, Repository, RepositoryKind, RepositoryService},
repository::{
FileEntrySearchResult, GitRepositoryService, GithubRepositoryService,
GitlabRepositoryService, Repository, RepositoryKind, RepositoryService,
},
Result,
};

struct RepositoryServiceImpl {
Expand Down

0 comments on commit 7c800ed

Please sign in to comment.