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

Code before:
                SchedulerGithubGitlabJob::NAME
            }
            BackgroundJobEvent::SyncThirdPartyRepositories(_) => SyncIntegrationJob::NAME,
            BackgroundJobEvent::WebCrawler(_) => WebCrawlerJob::NAME,
            BackgroundJobEvent::IndexGarbageCollection => IndexGarbageCollection::NAME,
            BackgroundJobEvent::Hourly => HourlyJob::NAME,
            BackgroundJobEvent::Daily => DailyJob::NAME,
        }
    }

    pub fn to_command(&self) -> String {
        serde_json::to_string(self).expect("Failed to serialize background job event")
    }
}

fn background_job_notification_name(event: &BackgroundJobEvent) -> &str {
    match event {
        BackgroundJobEvent::SchedulerGitRepository(_) => "Git repository synchronize",
        BackgroundJobEvent::SchedulerGithubGitlabRepository(_) => {
            "Github/Gitlab repository synchronize"
        }
        BackgroundJobEvent::SyncThirdPartyRepositories(_) => "Integration synchronize",
        BackgroundJobEvent::WebCrawler(_) => "Web crawler",
        BackgroundJobEvent::IndexGarbageCollection => "Index garbage collection",
        BackgroundJobEvent::Hourly => "Hourly",
        BackgroundJobEvent::Daily => "Daily",
    }
}

async fn notify_job_error(
    notification_service: Arc<dyn NotificationService>,
    err: &str,
    event: &BackgroundJobEvent,
    id: i64,
) {
    warn!("job {:?} failed: {:?}", event, err);
    let name = background_job_notification_name(event);
    if let Err(err) = notification_service
        .create(
            NotificationRecipient::Admin,
            &format!(
                r#"Job `{}` has failed.

Please examine the [logs](/jobs/detail?id={}) to determine the underlying issue.
"#,
                name,
                id.as_id()
            ),
        )
        .await
    {

Review comment (suggestion):
```suggestion
        BackgroundJobEvent::SchedulerGitRepository(_) => "Indexing Repository",
        BackgroundJobEvent::SchedulerGithubGitlabRepository(_) => {
            "Indexing Repository"
        }
        BackgroundJobEvent::SyncThirdPartyRepositories(_) => "Loading Repository",
        BackgroundJobEvent::WebCrawler(_) => "Web Indexing",
        BackgroundJobEvent::IndexGarbageCollection => "Garbage Collection",
        BackgroundJobEvent::Hourly => "Hourly",
        BackgroundJobEvent::Daily => "Daily",
```

Code after:
                SchedulerGithubGitlabJob::NAME
            }
            BackgroundJobEvent::SyncThirdPartyRepositories(_) => SyncIntegrationJob::NAME,
            BackgroundJobEvent::WebCrawler(_) => WebCrawlerJob::NAME,
            BackgroundJobEvent::IndexGarbageCollection => IndexGarbageCollection::NAME,
            BackgroundJobEvent::Hourly => HourlyJob::NAME,
            BackgroundJobEvent::Daily => DailyJob::NAME,
        }
    }

    pub fn to_command(&self) -> String {
        serde_json::to_string(self).expect("Failed to serialize background job event")
    }
}

fn background_job_notification_name(event: &BackgroundJobEvent) -> &str {
    match event {
        BackgroundJobEvent::SchedulerGitRepository(_) => "Indexing Repository",
        BackgroundJobEvent::SchedulerGithubGitlabRepository(_) => "Indexing Repository",
        BackgroundJobEvent::SyncThirdPartyRepositories(_) => "Loading Repository",
        BackgroundJobEvent::WebCrawler(_) => "Web Indexing",
        BackgroundJobEvent::IndexGarbageCollection => "Garbage Collection",
        BackgroundJobEvent::Hourly => "Hourly",
        BackgroundJobEvent::Daily => "Daily",
    }
}

async fn notify_job_error(
    notification_service: Arc<dyn NotificationService>,
    err: &str,
    event: &BackgroundJobEvent,
    id: i64,
) {
    warn!("job {:?} failed: {:?}", event, err);
    let name = background_job_notification_name(event);
    if let Err(err) = notification_service
        .create(
            NotificationRecipient::Admin,
            &format!(
                r#"Job **{}** has failed.

Please examine the [logs](/jobs/detail?id={}) to determine the underlying issue.
"#,
                name,
                id.as_id()
            ),
        )
        .await
    {
        warn!("Failed to send notification: {:?}", err);
    }