Skip to content

Commit

Permalink
Added a logic which consider Scheduled Cortesy Push time to increase …
Browse files Browse the repository at this point in the history
…sprint number. (#20452)
  • Loading branch information
DenisNikulin5 authored Sep 25, 2024
1 parent 434c551 commit c79a3c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions BuildConfigGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,36 @@ private static void MainUpdateTask(

private static int GetCurrentSprint()
{
// Scheduled time for Cortesy Push
var cortesyPushScheduleDay = DayOfWeek.Tuesday;
var cortesyPushUtcTime = new TimeOnly(8, 30); //UTC time

string url = "https://whatsprintis.it";
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");

string json = httpClient.GetStringAsync(url).Result;
JsonDocument currentSprintData = JsonDocument.Parse(json);
int currentSprint = currentSprintData.RootElement.GetProperty("sprint").GetInt32();
int week = currentSprintData.RootElement.GetProperty("week").GetInt32();

if (week == 3) // if it is the end of the current sprint
{
var nowUtc = DateTime.UtcNow;

// Increase sprint number if scheduled pipeline was already triggered
if (nowUtc.DayOfWeek > cortesyPushScheduleDay)
{
currentSprint++;
}
else if (nowUtc.DayOfWeek == cortesyPushScheduleDay)
{
if (TimeOnly.FromDateTime(nowUtc) >= cortesyPushUtcTime)
{
currentSprint++;
}
}
}

return currentSprint;
}
Expand Down

0 comments on commit c79a3c7

Please sign in to comment.