Repository: TabbyML/tabby
File: ee/tabby-webserver/src/service/background_job/third_party_integration.rs (Rust)

Code before:
        Ok(())
    }

    pub async fn cron(
        _now: DateTime<Utc>,
        repository: Arc<dyn ThirdPartyRepositoryService>,
        job: Arc<dyn JobService>,
    ) -> tabby_schema::Result<()> {
        for repository in repository
            .list_repositories_with_filter(None, None, Some(true), None, None, None, None)
            .await?
        {
            let _ = job
                .trigger(
                    BackgroundJobEvent::SchedulerGithubGitlabRepository(repository.id).to_command(),
                )
                .await;
        }
        Ok(())
    }
}

pub struct FetchState {
    updated_at: DateTime<Utc>,
    should_clean: bool,
}

async fn fetch_all_issues(
    integration: &Integration,
    repository: &ProvidedRepository,
) -> tabby_schema::Result<BoxStream<'static, (FetchState, StructuredDoc)>> {
    let s: BoxStream<(FetchState, StructuredDoc)> = match &integration.kind {
        IntegrationKind::Github | IntegrationKind::GithubSelfHosted => list_github_issues(
            &repository.source_id(),
            integration.api_base(),
            &repository.display_name,
            &integration.access_token,
        )
        .await?
        .boxed(),
        IntegrationKind::Gitlab | IntegrationKind::GitlabSelfHosted => list_gitlab_issues(
            &repository.source_id(),
            integration.api_base(),
            &repository.display_name,
            &integration.access_token,
        )
        .await?
        .boxed(),
    };

    Ok(s)

Review comment (suggestion):
```suggestion
pub StructuredDocState  {
    updated_at: DateTime<Utc>,
    deleted: bool,
}
```

Move definition to `tabby-index/src/structured_doc/public.rs`

Code after:
        repository: Arc<dyn ThirdPartyRepositoryService>,
        job: Arc<dyn JobService>,
    ) -> tabby_schema::Result<()> {
        for repository in repository
            .list_repositories_with_filter(None, None, Some(true), None, None, None, None)
            .await?
        {
            let _ = job
                .trigger(
                    BackgroundJobEvent::SchedulerGithubGitlabRepository(repository.id).to_command(),
                )
                .await;
        }
        Ok(())
    }
}

async fn fetch_all_issues(
    integration: &Integration,
    repository: &ProvidedRepository,
) -> tabby_schema::Result<BoxStream<'static, (StructuredDocState, StructuredDoc)>> {
    let s: BoxStream<(StructuredDocState, StructuredDoc)> = match &integration.kind {
        IntegrationKind::Github | IntegrationKind::GithubSelfHosted => list_github_issues(
            &repository.source_id(),
            integration.api_base(),
            &repository.display_name,
            &integration.access_token,
        )
        .await?
        .boxed(),
        IntegrationKind::Gitlab | IntegrationKind::GitlabSelfHosted => list_gitlab_issues(
            &repository.source_id(),
            integration.api_base(),
            &repository.display_name,
            &integration.access_token,
        )
        .await?
        .boxed(),
    };

    Ok(s)
}
async fn fetch_all_pulls(
    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,