diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-09 13:12:19 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-09 13:12:19 -0400 |
commit | 536d85cf9a55555782765cb9f6ef312cea9a4d5d (patch) | |
tree | fa645762e218e72dc459d5ff0ae352bc9f4196dc /src/SMAPI.Web | |
parent | cd2e8da43336b9aca68019b5991bedddd5d7d75e (diff) | |
download | SMAPI-536d85cf9a55555782765cb9f6ef312cea9a4d5d.tar.gz SMAPI-536d85cf9a55555782765cb9f6ef312cea9a4d5d.tar.bz2 SMAPI-536d85cf9a55555782765cb9f6ef312cea9a4d5d.zip |
optimise index page queries
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/Controllers/IndexController.cs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/SMAPI.Web/Controllers/IndexController.cs b/src/SMAPI.Web/Controllers/IndexController.cs index 0cc3c37a..a24b470c 100644 --- a/src/SMAPI.Web/Controllers/IndexController.cs +++ b/src/SMAPI.Web/Controllers/IndexController.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Web.Controllers private readonly IGitHubClient GitHub; /// <summary>The cache time for release info.</summary> - private readonly TimeSpan CacheTime = TimeSpan.FromSeconds(1); + private readonly TimeSpan CacheTime = TimeSpan.FromMinutes(10); /// <summary>The GitHub repository name to check for update.</summary> private readonly string RepositoryName = "Pathoschild/SMAPI"; @@ -79,11 +79,20 @@ namespace StardewModdingAPI.Web.Controllers { entry.AbsoluteExpiration = DateTimeOffset.UtcNow.Add(this.CacheTime); - // get releases - GitRelease stableRelease = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: false); - GitRelease betaRelease = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: true); - if (stableRelease.Tag == betaRelease.Tag) - betaRelease = null; + // get latest release (whether preview or stable) + GitRelease stableRelease = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: true); + + // split stable/prerelease if applicable + GitRelease betaRelease = null; + if (stableRelease.IsPrerelease) + { + GitRelease result = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: false); + if (result != null) + { + betaRelease = stableRelease; + stableRelease = result; + } + } // get versions ReleaseVersion[] stableVersions = this.ParseReleaseVersions(stableRelease).ToArray(); |