Skip to content

Commit

Permalink
Fixed how changelog shows nightly release, available, etc as it shoul…
Browse files Browse the repository at this point in the history
…d all be done in the backend.
  • Loading branch information
majora2007 committed Feb 5, 2024
1 parent 9f256d9 commit 66db906
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 255 deletions.
12 changes: 12 additions & 0 deletions API/DTOs/Update/UpdateNotificationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,16 @@ public class UpdateNotificationDto
/// Date of the publish
/// </summary>
public required string PublishDate { get; init; }
/// <summary>
/// Is the server on a nightly within this release
/// </summary>
public bool IsOnNightlyInRelease { get; set; }
/// <summary>
/// Is the server on an older version
/// </summary>
public bool IsReleaseNewer { get; set; }
/// <summary>
/// Is the server on this version
/// </summary>
public bool IsReleaseEqual { get; set; }
}
21 changes: 17 additions & 4 deletions API/Services/Tasks/VersionUpdaterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface IVersionUpdaterService
{
Task<UpdateNotificationDto?> CheckForUpdate();
Task PushUpdate(UpdateNotificationDto update);
Task<IEnumerable<UpdateNotificationDto>> GetAllReleases();
Task<IList<UpdateNotificationDto>> GetAllReleases();
Task<int> GetNumberOfReleasesBehind();
}

Expand Down Expand Up @@ -82,10 +82,21 @@ public VersionUpdaterService(ILogger<VersionUpdaterService> logger, IEventHub ev
return CreateDto(update);
}

public async Task<IEnumerable<UpdateNotificationDto>> GetAllReleases()
public async Task<IList<UpdateNotificationDto>> GetAllReleases()
{
var updates = await GetGithubReleases();
return updates.Select(CreateDto).Where(d => d != null)!;
var updateDtos = updates.Select(CreateDto)
.Where(d => d != null)
.OrderByDescending(d => d!.PublishDate)
.Select(d => d!)
.ToList();

// Find the latest dto
var latestRelease = updateDtos[0]!;
var isNightly = BuildInfo.Version > new Version(latestRelease.UpdateVersion);
latestRelease.IsOnNightlyInRelease = isNightly;

return updateDtos;
}

public async Task<int> GetNumberOfReleasesBehind()
Expand All @@ -108,7 +119,9 @@ public async Task<int> GetNumberOfReleasesBehind()
UpdateTitle = update.Name,
UpdateUrl = update.Html_Url,
IsDocker = OsInfo.IsDocker,
PublishDate = update.Published_At
PublishDate = update.Published_At,
IsReleaseEqual = BuildInfo.Version == updateVersion,
IsReleaseNewer = BuildInfo.Version < updateVersion,
};
}

Expand Down
Loading

0 comments on commit 66db906

Please sign in to comment.