Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Add a start time to the job and task (#3440)
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita authored Oct 4, 2023
1 parent acd1a36 commit 78f9049
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ public record Job(
StoredUserInfo? UserInfo,
string? Error = null,
DateTimeOffset? EndTime = null
) : StatefulEntityBase<JobState>(State) { }
) : StatefulEntityBase<JobState>(State) {

}

// This is like UserInfo but lacks the UPN:
public record StoredUserInfo(Guid? ApplicationId, Guid? ObjectId);
Expand Down
5 changes: 4 additions & 1 deletion src/ApiService/ApiService/OneFuzzTypes/Responses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public record TaskSearchResult(
List<NodeAssignment> 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
Expand Down Expand Up @@ -113,6 +115,7 @@ public static JobResponse ForJob(Job j, IEnumerable<IJobTaskInfo>? taskInfo)
UserInfo: j.UserInfo,
Timestamp: j.Timestamp
);
public DateTimeOffset? StartTime => EndTime is DateTimeOffset endTime ? endTime.Subtract(TimeSpan.FromHours(Config.Duration)) : null;
}

public record PoolGetResult(
Expand Down
2 changes: 2 additions & 0 deletions src/pytypes/onefuzztypes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 78f9049

Please sign in to comment.