-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[581] fix: Fix broken Documentation link in UI (#583)
* [581] fix: Fix broken Documentation link in UI * fix test
- Loading branch information
1 parent
7170c44
commit 75733a2
Showing
7 changed files
with
75 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Common; | ||
using Common.Observe; | ||
using Core.GitHub; | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Philosowaffle.Capability.ReleaseChecks.Model; | ||
using Serilog; | ||
|
||
namespace Api.Service; | ||
|
||
public interface IVersionInformationService | ||
{ | ||
Task<LatestReleaseInformation> GetLatestReleaseInformationAsync(); | ||
} | ||
|
||
public class VersionInformationService : IVersionInformationService | ||
{ | ||
private static readonly ILogger _logger = LogContext.ForClass<VersionInformationService>(); | ||
private static readonly object _lock = new object(); | ||
|
||
private readonly IGitHubReleaseCheckService _gitHubService; | ||
private readonly IMemoryCache _cache; | ||
|
||
public VersionInformationService(IGitHubReleaseCheckService gitHubService, IMemoryCache cache) | ||
{ | ||
_gitHubService = gitHubService; | ||
_cache = cache; | ||
} | ||
|
||
public Task<LatestReleaseInformation> GetLatestReleaseInformationAsync() | ||
{ | ||
using var tracing = Tracing.Trace($"{nameof(VersionInformationService)}.{nameof(GetLatestReleaseInformationAsync)}"); | ||
|
||
try | ||
{ | ||
lock (_lock) | ||
{ | ||
var key = $"LatestReleaseInformation"; | ||
return _cache.GetOrCreateAsync(key, (cacheEntry) => | ||
{ | ||
cacheEntry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5); | ||
|
||
return _gitHubService.GetLatestReleaseInformationAsync("philosowaffle", "peloton-to-garmin", Constants.AppVersion); | ||
}); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
_logger.Error("Failed to fetch Latest P2G Release information.", e); | ||
return Task.FromResult(new LatestReleaseInformation()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters