src/NuGetGallery/Services/JsonStatisticsService.cs
/// <summary>
/// Load a package downloads report.
/// </summary>
/// <param name="statisticsReportName">The name of the report to load.</param>
/// <param name="packagesAll">The model that should be hydrated with the report.</param>
/// <param name="packagesSummary">The model that should be hydrated with the summary of the report.</param>
/// <returns>The result of loading the report.</returns>
Load a package downloads report.
Load a package downloads report .
private async Task<StatisticsReportResult> LoadDownloadPackages(
            StatisticsReportName statisticsReportName,
            List<StatisticsPackagesItemViewModel> packagesAll,
            List<StatisticsPackagesItemViewModel> packagesSummary)
        {
            try
            {
                var reportName = (statisticsReportName + ".json").ToLowerInvariant();
                var reportContent = await _reportService.Load(reportName);
                if (reportContent == null)
                {
                    return StatisticsReportResult.Failed;
                }
                var results = JArray.Parse(reportContent.Content).Select(item =>
                    new StatisticsPackagesItemViewModel
                    {
                        PackageId = item["PackageId"].ToString(),
                        Downloads = item["Downloads"].Value<long>()
                    }
                );
                packagesAll.Clear();
                packagesAll.AddRange(results);
                packagesSummary.Clear();
                packagesSummary.AddRange(packagesAll.Take(10));
                return StatisticsReportResult.Success(reportContent.LastUpdatedUtc);
            }
            catch (Exception e)
            {
                QuietLog.LogHandledException(e);
                return StatisticsReportResult.Failed;
            }
        }
private async Task < StatisticsReportResult > LoadDownloadPackages ( StatisticsReportName statisticsReportName , List < StatisticsPackagesItemViewModel > packagesAll , List < StatisticsPackagesItemViewModel > packagesSummary ) { try { var reportName = ( statisticsReportName + " " ) . ToLowerInvariant ( ) ; var reportContent = await _reportService . Load ( reportName ) ; if ( reportContent == null ) { return StatisticsReportResult . Failed ; } var results = JArray . Parse ( reportContent . Content ) . Select ( item => new StatisticsPackagesItemViewModel { PackageId = item [ " " ] . ToString ( ) , Downloads = item [ " " ] . Value < long > ( ) } ) ; packagesAll . Clear ( ) ; packagesAll . AddRange ( results ) ; packagesSummary . Clear ( ) ; packagesSummary . AddRange ( packagesAll . Take ( 10 ) ) ; return StatisticsReportResult . Success ( reportContent . LastUpdatedUtc ) ; } catch ( Exception e ) { QuietLog . LogHandledException ( e ) ; return StatisticsReportResult . Failed ; } }
Load a package downloads report.
Load a package downloads report .
The result of loading the report.
The result of loading the report .
statisticsReportName
StatisticsReportName
The name of the report to load.
The name of the report to load .
packagesAll
List<StatisticsPackagesItemViewModel>
The model that should be hydrated with the report.
The model that should be hydrated with the report .
packagesSummary
List<StatisticsPackagesItemViewModel>
The model that should be hydrated with the summary of the report.
The model that should be hydrated with the summary of the report .