Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(index): fix gitlab third party integration by skip indexing gitlab pulls #3515

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
integration::{Integration, IntegrationKind, IntegrationService},
job::JobService,
repository::{ProvidedRepository, ThirdPartyRepositoryService},
CoreError,
};
use tracing::debug;

Expand Down Expand Up @@ -128,28 +129,34 @@
};

let pull_stream = match fetch_all_pulls(&integration, &repository).await {
Ok(s) => s,
Ok(s) => Some(s),

Check warning on line 132 in ee/tabby-webserver/src/service/background_job/third_party_integration.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/background_job/third_party_integration.rs#L132

Added line #L132 was not covered by tests
Err(e) => {
integration_service
.update_integration_sync_status(integration.id, Some(e.to_string()))
.await?;
logkit::error!("Failed to fetch pulls: {}", e);
return Err(e);
logkit::warn!("Failed to fetch pulls: {}", e);
None

Check warning on line 138 in ee/tabby-webserver/src/service/background_job/third_party_integration.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/background_job/third_party_integration.rs#L137-L138

Added lines #L137 - L138 were not covered by tests
}
};

stream! {
let mut count = 0;
let mut num_updated = 0;
for await (state, doc) in issue_stream.chain(pull_stream) {
if index.sync(state, doc).await {
num_updated += 1
}

count += 1;
if count % 100 == 0 {
logkit::info!("{} docs seen, {} docs updated", count, num_updated);
};
let combined_stream = if let Some(pull_stream) = pull_stream {
issue_stream.chain(pull_stream).boxed()
} else {
issue_stream.boxed()
};

for await (state, doc) in combined_stream {
if index.sync(state, doc).await {
num_updated += 1
}

count += 1;
if count % 100 == 0 {
logkit::info!("{} docs seen, {} docs updated", count, num_updated);
};

Check warning on line 159 in ee/tabby-webserver/src/service/background_job/third_party_integration.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/background_job/third_party_integration.rs#L145-L159

Added lines #L145 - L159 were not covered by tests
}

logkit::info!("{} docs seen, {} docs updated", count, num_updated);
Expand Down Expand Up @@ -209,14 +216,17 @@
integration: &Integration,
repository: &ProvidedRepository,
) -> tabby_schema::Result<BoxStream<'static, (StructuredDocState, StructuredDoc)>> {
let s: BoxStream<(StructuredDocState, StructuredDoc)> = list_github_pulls(
&repository.source_id(),
integration.api_base(),
&repository.display_name,
&integration.access_token,
)
.await?
.boxed();

Ok(s)
match &integration.kind {
IntegrationKind::Github | IntegrationKind::GithubSelfHosted => Ok(list_github_pulls(
&repository.source_id(),
integration.api_base(),
&repository.display_name,
&integration.access_token,
)
.await?
.boxed()),
IntegrationKind::Gitlab | IntegrationKind::GitlabSelfHosted => Err(CoreError::Other(
anyhow::anyhow!("Gitlab does not support pull requests yet"),
)),

Check warning on line 230 in ee/tabby-webserver/src/service/background_job/third_party_integration.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-webserver/src/service/background_job/third_party_integration.rs#L219-L230

Added lines #L219 - L230 were not covered by tests
}
}
Loading