Skip to content

Commit

Permalink
Allow toggling repository active status
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Apr 9, 2024
1 parent 8c4480c commit 6ff67ac
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ee/tabby-db/src/github_repository_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,26 @@ impl DbConn {
.await?;
Ok(repos)
}

Check warning on line 155 in ee/tabby-db/src/github_repository_provider.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-db/src/github_repository_provider.rs#L130-L155

Added lines #L130 - L155 were not covered by tests

pub async fn update_github_provided_repository_active(
&self,
id: i64,
active: bool,
) -> Result<()> {
let not_active = !active;
let res = query!(
"UPDATE github_provided_repositories SET active = ? WHERE id = ? AND active = ?",
active,
id,
not_active
)
.execute(&self.pool)
.await?;

Check warning on line 170 in ee/tabby-db/src/github_repository_provider.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-db/src/github_repository_provider.rs#L157-L170

Added lines #L157 - L170 were not covered by tests

if res.rows_affected() != 1 {
return Err(anyhow!("Repository active status was not changed"));
}

Ok(())
}

Check warning on line 177 in ee/tabby-db/src/github_repository_provider.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-db/src/github_repository_provider.rs#L172-L177

Added lines #L172 - L177 were not covered by tests
}
2 changes: 2 additions & 0 deletions ee/tabby-webserver/src/schema/github_repository_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ pub trait GithubRepositoryProviderService: Send + Sync {
first: Option<usize>,
last: Option<usize>,
) -> Result<Vec<GithubProvidedRepository>>;

async fn update_github_provided_repository_active(&self, id: ID, active: bool) -> Result<()>;
}
12 changes: 12 additions & 0 deletions ee/tabby-webserver/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,18 @@ impl Mutation {
.await?;
Ok(true)
}

async fn update_github_provided_repository_active(
ctx: &Context,
id: ID,
active: bool,
) -> Result<bool> {
ctx.locator
.github_repository_provider()
.update_github_provided_repository_active(id, active)
.await?;
Ok(true)
}
}

async fn check_analytic_access(ctx: &Context, users: &[ID]) -> Result<(), CoreError> {
Expand Down
7 changes: 7 additions & 0 deletions ee/tabby-webserver/src/service/github_repository_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,11 @@ impl GithubRepositoryProviderService for GithubRepositoryProviderServiceImpl {
.map(GithubProvidedRepository::from)
.collect())
}

Check warning on line 101 in ee/tabby-webserver/src/service/github_repository_provider.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/github_repository_provider.rs#L97-L101

Added lines #L97 - L101 were not covered by tests

async fn update_github_provided_repository_active(&self, id: ID, active: bool) -> Result<()> {
self.db
.update_github_provided_repository_active(id.as_rowid()? as i64, active)
.await?;
Ok(())
}

Check warning on line 108 in ee/tabby-webserver/src/service/github_repository_provider.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/github_repository_provider.rs#L103-L108

Added lines #L103 - L108 were not covered by tests
}

0 comments on commit 6ff67ac

Please sign in to comment.