From 78f9049d9b91e00c1ec2123c03b845317274f35e Mon Sep 17 00:00:00 2001 From: Cheick Keita Date: Wed, 4 Oct 2023 13:44:29 -0700 Subject: [PATCH] Add a start time to the job and task (#3440) --- src/ApiService/ApiService/OneFuzzTypes/Model.cs | 4 +++- src/ApiService/ApiService/OneFuzzTypes/Responses.cs | 5 ++++- src/pytypes/onefuzztypes/models.py | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ApiService/ApiService/OneFuzzTypes/Model.cs b/src/ApiService/ApiService/OneFuzzTypes/Model.cs index 3d67de106d..23811e9fe0 100644 --- a/src/ApiService/ApiService/OneFuzzTypes/Model.cs +++ b/src/ApiService/ApiService/OneFuzzTypes/Model.cs @@ -978,7 +978,9 @@ public record Job( StoredUserInfo? UserInfo, string? Error = null, DateTimeOffset? EndTime = null -) : StatefulEntityBase(State) { } +) : StatefulEntityBase(State) { + +} // This is like UserInfo but lacks the UPN: public record StoredUserInfo(Guid? ApplicationId, Guid? ObjectId); diff --git a/src/ApiService/ApiService/OneFuzzTypes/Responses.cs b/src/ApiService/ApiService/OneFuzzTypes/Responses.cs index b98856adb0..c1067305ad 100644 --- a/src/ApiService/ApiService/OneFuzzTypes/Responses.cs +++ b/src/ApiService/ApiService/OneFuzzTypes/Responses.cs @@ -52,7 +52,9 @@ public record TaskSearchResult( List Nodes, [property: JsonPropertyName("Timestamp")] // must retain capital T for backcompat DateTimeOffset? Timestamp -) : BaseResponse(); +) : BaseResponse() { + public DateTimeOffset? StartTime => EndTime is DateTimeOffset endTime ? endTime.Subtract(TimeSpan.FromHours(Config.Task.Duration)) : null; +} public record BoolResult( bool Result @@ -113,6 +115,7 @@ public static JobResponse ForJob(Job j, IEnumerable? taskInfo) UserInfo: j.UserInfo, Timestamp: j.Timestamp ); + public DateTimeOffset? StartTime => EndTime is DateTimeOffset endTime ? endTime.Subtract(TimeSpan.FromHours(Config.Duration)) : null; } public record PoolGetResult( diff --git a/src/pytypes/onefuzztypes/models.py b/src/pytypes/onefuzztypes/models.py index 4b115a3c79..70e9831e0b 100644 --- a/src/pytypes/onefuzztypes/models.py +++ b/src/pytypes/onefuzztypes/models.py @@ -747,6 +747,7 @@ class Task(BaseModel): events: Optional[List[TaskEventSummary]] nodes: Optional[List[NodeAssignment]] user_info: Optional[UserInfo] + start_time: Optional[datetime] = None class Job(BaseModel): @@ -758,6 +759,7 @@ class Job(BaseModel): end_time: Optional[datetime] = None task_info: Optional[List[Union[Task, JobTaskInfo]]] user_info: Optional[UserInfo] + start_time: Optional[datetime] = None class NetworkConfig(BaseModel):