src/NuGetGallery/Services/JsonStatisticsService.cs
/// <summary>
/// Refresh or load the statistics service's reports. No-ops if <see cref="_lastRefresh"/>
/// is within <see cref="_refreshInterval"/>.
/// </summary>
/// <returns>A task that completes when the reports have finished.</returns>
Refresh or load the statistics service's reports. No-ops if
is within .
Refresh or load the statistics service ' s reports . No - ops if is within .
public async Task Refresh()
        {
            if (!ShouldRefresh())
            {
                return;
            }
            await _reportSemaphore.WaitAsync();
            try
            {
                if (!ShouldRefresh())
                {
                    return;
                }
                var availablity = await Task.WhenAll(
                    LoadDownloadPackages(),
                    LoadDownloadPackageVersions(),
                    LoadDownloadCommunityPackages(),
                    LoadDownloadCommunityPackageVersions(),
                    LoadNuGetClientVersion(),
                    LoadLast6Weeks());
                PackageDownloadsResult = availablity[0];
                PackageVersionDownloadsResult = availablity[1];
                CommunityPackageDownloadsResult = availablity[2];
                CommunityPackageVersionDownloadsResult = availablity[3];
                NuGetClientVersionResult = availablity[4];
                Last6WeeksResult = availablity[5];
                LastUpdatedUtc = availablity
                    .Where(r => r.LastUpdatedUtc.HasValue)
                    .OrderByDescending(r => r.LastUpdatedUtc.Value)
                    .Select(r => r.LastUpdatedUtc)
                    .FirstOrDefault();
                _lastRefresh = _dateTimeProvider.UtcNow;
            }
            finally
            {
                _reportSemaphore.Release();
            }
        }
public async Task Refresh ( ) { if ( ! ShouldRefresh ( ) ) { return ; } await _reportSemaphore . WaitAsync ( ) ; try { if ( ! ShouldRefresh ( ) ) { return ; } var availablity = await Task . WhenAll ( LoadDownloadPackages ( ) , LoadDownloadPackageVersions ( ) , LoadDownloadCommunityPackages ( ) , LoadDownloadCommunityPackageVersions ( ) , LoadNuGetClientVersion ( ) , LoadLast6Weeks ( ) ) ; PackageDownloadsResult = availablity [ 0 ] ; PackageVersionDownloadsResult = availablity [ 1 ] ; CommunityPackageDownloadsResult = availablity [ 2 ] ; CommunityPackageVersionDownloadsResult = availablity [ 3 ] ; NuGetClientVersionResult = availablity [ 4 ] ; Last6WeeksResult = availablity [ 5 ] ; LastUpdatedUtc = availablity . Where ( r => r . LastUpdatedUtc . HasValue ) . OrderByDescending ( r => r . LastUpdatedUtc . Value ) . Select ( r => r . LastUpdatedUtc ) . FirstOrDefault ( ) ; _lastRefresh = _dateTimeProvider . UtcNow ; } finally { _reportSemaphore . Release ( ) ; } }
Refresh or load the statistics service's reports.
Refresh or load the statistics service ' s reports .
A task that completes when the reports have finished.
A task that completes when the reports have finished .