Skip to content

Commit

Permalink
refactor(webserver): rename import github / gitlab job name (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys authored Apr 30, 2024
1 parent 767cd16 commit 1774b54
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
28 changes: 18 additions & 10 deletions ee/tabby-webserver/src/cron/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,26 @@ pub async fn register_jobs(
.await;

controller
.register_public("github_repositories", &every_two_hours(), move |context| {
let context = context.clone();
let github = github.clone();
Box::pin(async move { github::refresh_all_repositories(context, github).await })
})
.register_public(
"import_github_repositories",
&every_two_hours(),
move |context| {
let context = context.clone();
let github = github.clone();
Box::pin(async move { github::refresh_all_repositories(context, github).await })
},
)
.await;

controller
.register_public("gitlab_repositories", &every_two_hours(), move |context| {
let gitlab = gitlab.clone();
let context = context.clone();
Box::pin(async move { gitlab::refresh_all_repositories(context, gitlab).await })
})
.register_public(
"import_gitlab_repositories",
&every_two_hours(),
move |context| {
let gitlab = gitlab.clone();
let context = context.clone();
Box::pin(async move { gitlab::refresh_all_repositories(context, gitlab).await })
},
)
.await;
}
22 changes: 12 additions & 10 deletions ee/tabby-webserver/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,14 @@ impl Query {

// FIXME(meng): This is a temporary solution to expose the list of jobs, we should consider switching to a enum based approach.
async fn jobs() -> Result<Vec<String>> {
Ok(
vec!["scheduler", "github_repositories", "gitlab_repositories"]
.into_iter()
.map(Into::into)
.collect(),
)
Ok(vec![
"scheduler",
"import_github_repositories",
"import_gitlab_repositories",
]
.into_iter()
.map(Into::into)
.collect())
}

async fn daily_stats_in_past_year(
Expand Down Expand Up @@ -787,7 +789,7 @@ impl Mutation {
.github()
.create_provider(input.display_name, input.access_token)
.await?;
ctx.locator.job().schedule("github_repositories");
ctx.locator.job().schedule("import_github_repositories");
Ok(id)
}

Expand All @@ -812,7 +814,7 @@ impl Mutation {
.github()
.update_provider(input.id, input.display_name, input.access_token)
.await?;
ctx.locator.job().schedule("github_repositories");
ctx.locator.job().schedule("import_github_repositories");
Ok(true)
}

Expand Down Expand Up @@ -841,7 +843,7 @@ impl Mutation {
.gitlab()
.create_provider(input.display_name, input.access_token)
.await?;
ctx.locator.job().schedule("gitlab_repositories");
ctx.locator.job().schedule("import_gitlab_repositories");
Ok(id)
}

Expand All @@ -866,7 +868,7 @@ impl Mutation {
.gitlab()
.update_provider(input.id, input.display_name, input.access_token)
.await?;
ctx.locator.job().schedule("gitlab_repositories");
ctx.locator.job().schedule("import_gitlab_repositories");
Ok(true)
}

Expand Down

0 comments on commit 1774b54

Please sign in to comment.