mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:54:55 +08:00
@@ -264,13 +264,24 @@ type ScheduleRunParams struct {
|
||||
MaxRuns *uint64 `json:"max_runs,omitempty"`
|
||||
}
|
||||
|
||||
// TranslationTaskUnitResultParam is the dashboard/manual-review subset of one
|
||||
// TextUnit result accepted by Rust translation.task.update.
|
||||
type TranslationTaskUnitResultParam struct {
|
||||
UnitID string `json:"unit_id"`
|
||||
SourceText string `json:"source_text"`
|
||||
TranslatedText string `json:"translated_text"`
|
||||
}
|
||||
|
||||
// TranslationTaskUpdateParams is used by translation.task.update to persist
|
||||
// provider worker state for one task in the current official release.
|
||||
// provider worker state and optional manual-review text for one task in the
|
||||
// current official release.
|
||||
type TranslationTaskUpdateParams struct {
|
||||
TaskID string `json:"task_id"`
|
||||
Status string `json:"status"`
|
||||
FailureReason string `json:"failure_reason,omitempty"`
|
||||
ProviderRunID string `json:"provider_run_id,omitempty"`
|
||||
TaskID string `json:"task_id"`
|
||||
Status string `json:"status"`
|
||||
FailureReason string `json:"failure_reason,omitempty"`
|
||||
ProviderRunID string `json:"provider_run_id,omitempty"`
|
||||
Provider string `json:"provider,omitempty"`
|
||||
TranslationResults []TranslationTaskUnitResultParam `json:"translation_results,omitempty"`
|
||||
}
|
||||
|
||||
// TranslationTaskListParams filters the Rust-owned translation task queue.
|
||||
|
||||
@@ -434,9 +434,14 @@ func TestTranslationTaskUpdateSendsWorkerParams(t *testing.T) {
|
||||
t.Fatalf("decode params: %v", err)
|
||||
}
|
||||
if params.TaskID != "textunit/v-current/Scenario" ||
|
||||
params.Status != "failed" ||
|
||||
params.FailureReason != "provider rejected payload" ||
|
||||
params.ProviderRunID != "provider-run-1" {
|
||||
params.Status != "completed" ||
|
||||
params.FailureReason != "" ||
|
||||
params.ProviderRunID != "provider-run-1" ||
|
||||
params.Provider != "manual" ||
|
||||
len(params.TranslationResults) != 1 ||
|
||||
params.TranslationResults[0].UnitID != "direct:a#unit:0" ||
|
||||
params.TranslationResults[0].SourceText != "source" ||
|
||||
params.TranslationResults[0].TranslatedText != "译文" {
|
||||
t.Fatalf("params = %#v", params)
|
||||
}
|
||||
return testResponse{
|
||||
@@ -444,16 +449,21 @@ func TestTranslationTaskUpdateSendsWorkerParams(t *testing.T) {
|
||||
OK: true,
|
||||
Status: "ok",
|
||||
RequestID: "req-test-translation-update",
|
||||
Data: map[string]any{"task_status": "failed"},
|
||||
Data: map[string]any{"task_status": "completed"},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
raw, err := client.TranslationTaskUpdate(context.Background(), TranslationTaskUpdateParams{
|
||||
TaskID: "textunit/v-current/Scenario",
|
||||
Status: "failed",
|
||||
FailureReason: "provider rejected payload",
|
||||
Status: "completed",
|
||||
ProviderRunID: "provider-run-1",
|
||||
Provider: "manual",
|
||||
TranslationResults: []TranslationTaskUnitResultParam{{
|
||||
UnitID: "direct:a#unit:0",
|
||||
SourceText: "source",
|
||||
TranslatedText: "译文",
|
||||
}},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TranslationTaskUpdate error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user