Skip to content

Commit 8c6ecfb

Browse files
Updated how estimatedNextRunTime is set from the WebApi GetJobsHandler
1 parent 4c6b61d commit 8c6ecfb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Service/GroupMembershipManagement/Hosts/WebApi/Services.WebApi/GetJobsHandler.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,32 @@ protected override async Task<GetJobsResponse> ExecuteCoreAsync(GetJobsRequest r
7676
foreach (var job in jobs)
7777
{
7878
var type = job.Destination.Contains("GroupMembership") ? "Group" : "Channel";
79+
var currentTime = DateTime.UtcNow;
80+
var jobStartsInFuture = currentTime < job.StartDate;
81+
var jobScheduledForFuture = currentTime < job.ScheduledDate;
82+
83+
DateTime estimatedNextRunTime;
84+
if (!jobStartsInFuture && !jobScheduledForFuture)
85+
{
86+
estimatedNextRunTime = job.LastRunTime.AddHours(job.Period);
87+
}
88+
else if (jobStartsInFuture)
89+
{
90+
estimatedNextRunTime = job.StartDate;
91+
}
92+
else
93+
{
94+
estimatedNextRunTime = job.ScheduledDate;
95+
}
96+
7997
var dto = new SyncJobDTO
8098
(
8199
job.Id,
82100
job.TargetOfficeGroupId,
83101
job.Status,
84102
job.Period,
85103
job.LastSuccessfulRunTime,
86-
job.StartDate > job.ScheduledDate ? job.StartDate : job.ScheduledDate
104+
estimatedNextRunTime
87105
)
88106
{
89107
TargetGroupName = targetGroups.ContainsKey(job.TargetOfficeGroupId) ? targetGroups[job.TargetOfficeGroupId].Name : null,

0 commit comments

Comments
 (0)