mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:54:55 +08:00
fix(bat-api): 完成 issue #19 同机 live 联调
This commit is contained in:
@@ -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,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user