diff --git a/src/Serval.Client/Client.g.cs b/src/Serval.Client/Client.g.cs index 7e30ff85..d1987abc 100644 --- a/src/Serval.Client/Client.g.cs +++ b/src/Serval.Client/Client.g.cs @@ -4427,6 +4427,9 @@ public partial class TranslationBuild [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string? Message { get; set; } = default!; + [Newtonsoft.Json.JsonProperty("queueDepth", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int? QueueDepth { get; set; } = default!; + /// /// The current build job state. /// diff --git a/src/Serval.Grpc/Protos/serval/translation/v1/platform.proto b/src/Serval.Grpc/Protos/serval/translation/v1/platform.proto index a56680ae..0c5773e3 100644 --- a/src/Serval.Grpc/Protos/serval/translation/v1/platform.proto +++ b/src/Serval.Grpc/Protos/serval/translation/v1/platform.proto @@ -21,6 +21,7 @@ message UpdateBuildStatusRequest { int32 step = 2; optional double percent_completed = 3; optional string message = 4; + optional int32 queue_depth = 5; } message BuildStartedRequest { diff --git a/src/Serval.Translation/Contracts/TranslationBuildDto.cs b/src/Serval.Translation/Contracts/TranslationBuildDto.cs index 3e914b44..65fa4558 100644 --- a/src/Serval.Translation/Contracts/TranslationBuildDto.cs +++ b/src/Serval.Translation/Contracts/TranslationBuildDto.cs @@ -12,6 +12,8 @@ public class TranslationBuildDto public double? PercentCompleted { get; set; } public string? Message { get; set; } + public int? QueueDepth { get; set; } + /// /// The current build job state. /// diff --git a/src/Serval.Translation/Controllers/TranslationEnginesController.cs b/src/Serval.Translation/Controllers/TranslationEnginesController.cs index dfbffbd6..f5ad4dd0 100644 --- a/src/Serval.Translation/Controllers/TranslationEnginesController.cs +++ b/src/Serval.Translation/Controllers/TranslationEnginesController.cs @@ -1066,6 +1066,7 @@ private TranslationBuildDto Map(Build source) Step = source.Step, PercentCompleted = source.PercentCompleted, Message = source.Message, + QueueDepth = source.QueueDepth, State = source.State, DateFinished = source.DateFinished, Options = JsonSerializer.Serialize(source.Options) diff --git a/src/Serval.Translation/Models/Build.cs b/src/Serval.Translation/Models/Build.cs index d934a35c..fbfe2b3f 100644 --- a/src/Serval.Translation/Models/Build.cs +++ b/src/Serval.Translation/Models/Build.cs @@ -10,6 +10,7 @@ public class Build : IEntity public int Step { get; set; } public double? PercentCompleted { get; set; } public string? Message { get; set; } + public int? QueueDepth { get; set; } public JobState State { get; set; } = JobState.Pending; public DateTime? DateFinished { get; set; } public IDictionary? Options { get; set; } diff --git a/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs b/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs index 665ac0fd..2b6a4edd 100644 --- a/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs +++ b/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs @@ -246,6 +246,8 @@ await _builds.UpdateAsync( } if (request.HasMessage) u.Set(b => b.Message, request.Message); + if (request.HasQueueDepth) + u.Set(b => b.QueueDepth, request.QueueDepth); }, cancellationToken: context.CancellationToken ); diff --git a/tests/Serval.E2ETests/ServalApiTests.cs b/tests/Serval.E2ETests/ServalApiTests.cs index 7e12c8fb..15857f6b 100644 --- a/tests/Serval.E2ETests/ServalApiTests.cs +++ b/tests/Serval.E2ETests/ServalApiTests.cs @@ -176,7 +176,7 @@ public async Task NmtQueueMultiple() Assert.Multiple(async () => { Assert.That( - int.Parse(newestEngineCurrentBuild.Message?.Split(": ").Last() ?? "0"), + newestEngineCurrentBuild.QueueDepth, Is.GreaterThan(0), message: builds );