Skip to content

Commit c79a3c7

Browse files
Added a logic which consider Scheduled Cortesy Push time to increase sprint number. (#20452)
1 parent 434c551 commit c79a3c7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

BuildConfigGen/Program.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,36 @@ private static void MainUpdateTask(
313313

314314
private static int GetCurrentSprint()
315315
{
316+
// Scheduled time for Cortesy Push
317+
var cortesyPushScheduleDay = DayOfWeek.Tuesday;
318+
var cortesyPushUtcTime = new TimeOnly(8, 30); //UTC time
319+
316320
string url = "https://whatsprintis.it";
317321
var httpClient = new HttpClient();
318322
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
319323

320324
string json = httpClient.GetStringAsync(url).Result;
321325
JsonDocument currentSprintData = JsonDocument.Parse(json);
322326
int currentSprint = currentSprintData.RootElement.GetProperty("sprint").GetInt32();
327+
int week = currentSprintData.RootElement.GetProperty("week").GetInt32();
328+
329+
if (week == 3) // if it is the end of the current sprint
330+
{
331+
var nowUtc = DateTime.UtcNow;
332+
333+
// Increase sprint number if scheduled pipeline was already triggered
334+
if (nowUtc.DayOfWeek > cortesyPushScheduleDay)
335+
{
336+
currentSprint++;
337+
}
338+
else if (nowUtc.DayOfWeek == cortesyPushScheduleDay)
339+
{
340+
if (TimeOnly.FromDateTime(nowUtc) >= cortesyPushUtcTime)
341+
{
342+
currentSprint++;
343+
}
344+
}
345+
}
323346

324347
return currentSprint;
325348
}

0 commit comments

Comments
 (0)