fix(bat-api): 完成 issue #19 同机 live 联调
bat-rust / Build and test Go API (push) Canceled after 0s
bat-rust / Build and test Rust (push) Canceled after 0s

This commit is contained in:
2026-08-29 22:58:01 +08:00
parent 90083302a2
commit 7f465523e1
22 changed files with 819 additions and 115 deletions
+36 -24
View File
@@ -405,6 +405,25 @@ pub struct PersistedTranslationTask {
pub provider_run_id: Option<String>,
}
/// Mutable persistence metadata associated with an official TextUnit task.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PersistedTranslationTaskState {
/// Current worker state.
pub task_status: TranslationTaskStatus,
/// Provider failure reason, if the worker recorded one.
pub failure_reason: Option<String>,
/// Number of provider attempts.
pub attempt_count: u32,
/// First persistence time as Unix seconds.
pub created_unix_seconds: u64,
/// Last state or metadata update time as Unix seconds.
pub updated_unix_seconds: u64,
/// Completion time as Unix seconds, if completed.
pub completed_unix_seconds: Option<u64>,
/// Provider-side run identifier, if known.
pub provider_run_id: Option<String>,
}
/// Result of synchronizing an immutable release queue into SQLite.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct TranslationTaskSyncReport {
@@ -860,25 +879,16 @@ type TranslationTaskRow = (
impl PersistedTranslationTask {
/// Builds a persisted translation task from an immutable queue task.
pub fn from_task(
task: OfficialTextUnitTask,
task_status: TranslationTaskStatus,
failure_reason: Option<String>,
attempt_count: u32,
created_unix_seconds: u64,
updated_unix_seconds: u64,
completed_unix_seconds: Option<u64>,
provider_run_id: Option<String>,
) -> Self {
pub fn from_task(task: OfficialTextUnitTask, state: PersistedTranslationTaskState) -> Self {
Self {
task,
task_status,
failure_reason,
attempt_count,
created_unix_seconds,
updated_unix_seconds,
completed_unix_seconds,
provider_run_id,
task_status: state.task_status,
failure_reason: state.failure_reason,
attempt_count: state.attempt_count,
created_unix_seconds: state.created_unix_seconds,
updated_unix_seconds: state.updated_unix_seconds,
completed_unix_seconds: state.completed_unix_seconds,
provider_run_id: state.provider_run_id,
}
}
@@ -892,13 +902,15 @@ impl PersistedTranslationTask {
};
Self::from_task(
task,
task_status,
failure_reason,
0,
generated_unix_seconds,
generated_unix_seconds,
None,
None,
PersistedTranslationTaskState {
task_status,
failure_reason,
attempt_count: 0,
created_unix_seconds: generated_unix_seconds,
updated_unix_seconds: generated_unix_seconds,
completed_unix_seconds: None,
provider_run_id: None,
},
)
}