diff --git a/content/PROD/Home.html b/content/PROD/Home.html index f7cb5f69c1..2dfb6d910b 100644 --- a/content/PROD/Home.html +++ b/content/PROD/Home.html @@ -31,7 +31,7 @@

What is NuGet?

Latest NuGet Releases

- NuGet 3.5 for Visual Studio 2015 was released on October 27th, 2016. NuGet 2.12 for Visual Studio 2013 was released on June 27th 2016. Download these releases from http://nuget.org/downloads. + NuGet 3.5 for Visual Studio 2015 was released on October 27th, 2016. NuGet 2.12 for Visual Studio 2013 was released on June 27th 2016. Download these releases from downloads.

For details about what's in the 3.5 release, read the release notes. diff --git a/src/NuGetGallery/App_Start/OwinStartup.cs b/src/NuGetGallery/App_Start/OwinStartup.cs index e021afb78c..eb35010f5a 100644 --- a/src/NuGetGallery/App_Start/OwinStartup.cs +++ b/src/NuGetGallery/App_Start/OwinStartup.cs @@ -68,7 +68,7 @@ public static void Configuration(IAppBuilder app) // Add processors telemetryProcessorChainBuilder.Use(next => { - var processor = new TelemetryResponseCodeProcessor(next); + var processor = new RequestTelemetryProcessor(next); processor.SuccessfulResponseCodes.Add(400); processor.SuccessfulResponseCodes.Add(404); @@ -76,6 +76,9 @@ public static void Configuration(IAppBuilder app) return processor; }); + telemetryProcessorChainBuilder.Use( + next => new ExceptionTelemetryProcessor(next, Telemetry.TelemetryClient)); + // Note: sampling rate must be a factor 100/N where N is a whole number // e.g.: 50 (= 100/2), 33.33 (= 100/3), 25 (= 100/4), ... // https://azure.microsoft.com/en-us/documentation/articles/app-insights-sampling/ diff --git a/src/NuGetGallery/NuGetGallery.csproj b/src/NuGetGallery/NuGetGallery.csproj index 447abcfdc3..3c2634051e 100644 --- a/src/NuGetGallery/NuGetGallery.csproj +++ b/src/NuGetGallery/NuGetGallery.csproj @@ -443,8 +443,8 @@ ..\..\packages\NuGet.Services.KeyVault.1.0.0.0\lib\net45\NuGet.Services.KeyVault.dll True - - ..\..\packages\NuGet.Services.Logging.2.2.1\lib\net452\NuGet.Services.Logging.dll + + ..\..\packages\NuGet.Services.Logging.2.2.3\lib\net452\NuGet.Services.Logging.dll True diff --git a/src/NuGetGallery/Queries/AutoCompleteDatabasePackageVersionsQuery.cs b/src/NuGetGallery/Queries/AutoCompleteDatabasePackageVersionsQuery.cs index c3d880a13a..df0f4f62e7 100644 --- a/src/NuGetGallery/Queries/AutoCompleteDatabasePackageVersionsQuery.cs +++ b/src/NuGetGallery/Queries/AutoCompleteDatabasePackageVersionsQuery.cs @@ -14,7 +14,7 @@ public class AutoCompleteDatabasePackageVersionsQuery private const string _sqlFormat = @"SELECT p.[Version] FROM Packages p (NOLOCK) JOIN PackageRegistrations pr (NOLOCK) on pr.[Key] = p.PackageRegistrationKey -WHERE {0} AND pr.ID = {{0}} +WHERE p.[Deleted] <> 1 AND {0} AND pr.ID = {{0}} {1}"; public AutoCompleteDatabasePackageVersionsQuery(IEntitiesContext entities) diff --git a/src/NuGetGallery/Scripts/stats.js b/src/NuGetGallery/Scripts/stats.js index e44c47e2e9..7b206d0d56 100644 --- a/src/NuGetGallery/Scripts/stats.js +++ b/src/NuGetGallery/Scripts/stats.js @@ -12,8 +12,6 @@ // var section = $('section.aggstatserr'); // section.show(); }); - - setTimeout(function () { getStats(currData); }, 30000); } function update(data, currData, key) { diff --git a/src/NuGetGallery/Telemetry/Telemetry.cs b/src/NuGetGallery/Telemetry/Telemetry.cs index 605a4cf605..08ace7c533 100644 --- a/src/NuGetGallery/Telemetry/Telemetry.cs +++ b/src/NuGetGallery/Telemetry/Telemetry.cs @@ -9,13 +9,18 @@ namespace NuGetGallery { internal static class Telemetry { - private static readonly TelemetryClient _telemetryClient = new TelemetryClient(); + static Telemetry() + { + TelemetryClient = new TelemetryClient(); + } + + internal static TelemetryClient TelemetryClient { get; } public static void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) { try { - _telemetryClient.TrackEvent(eventName, properties, metrics); + TelemetryClient.TrackEvent(eventName, properties, metrics); } catch { @@ -27,7 +32,7 @@ public static void TrackException(Exception exception, IDictionary pack TotalDaysSinceCreated = 0; DownloadsPerDay = 0; } + + DownloadsPerDayLabel = DownloadsPerDay < 1 ? "<1" : DownloadsPerDay.ToNuGetNumberString(); } public void SetPendingMetadata(PackageEdit pendingMetadata) @@ -84,5 +86,7 @@ public bool HasNewerPrerelease } public bool? IsIndexed { get; set; } + + public string DownloadsPerDayLabel { get; private set; } } } \ No newline at end of file diff --git a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml index 459f71d804..e7b8ba935f 100644 --- a/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml +++ b/src/NuGetGallery/Views/Packages/DisplayPackage.cshtml @@ -40,7 +40,7 @@

@(Model.DownloadCount == 1 ? "Download" : "Downloads") of v @Model.Version

-

@(Model.DownloadsPerDay <= 1 ? "<1" : Model.DownloadsPerDay.ToNuGetNumberString())

+

@(Model.DownloadsPerDayLabel)

Average downloads per day

diff --git a/src/NuGetGallery/Views/Statistics/_PivotTable.cshtml b/src/NuGetGallery/Views/Statistics/_PivotTable.cshtml index 9ac299af15..ee465c53d6 100644 --- a/src/NuGetGallery/Views/Statistics/_PivotTable.cshtml +++ b/src/NuGetGallery/Views/Statistics/_PivotTable.cshtml @@ -11,7 +11,7 @@
- +
diff --git a/src/NuGetGallery/packages.config b/src/NuGetGallery/packages.config index e9bd26cbaf..237f2e9997 100644 --- a/src/NuGetGallery/packages.config +++ b/src/NuGetGallery/packages.config @@ -83,7 +83,7 @@ - + diff --git a/tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs b/tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs index 822a1118a8..9d8edaa31a 100644 --- a/tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs +++ b/tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Linq; using NuGet.Versioning; using Xunit; @@ -44,5 +45,68 @@ public void TheCtorSortsPackageVersionsProperly() Assert.Equal("1.0.2", packageVersions[1].Version); Assert.Equal("1.0.10", packageVersions[0].Version); } + + [Fact] + public void DownloadsPerDayLabelShowsLessThanOneWhenAverageBelowOne() + { + // Arrange + const int downloadCount = 10; + const int daysSinceCreated = 11; + + var package = new Package + { + Dependencies = Enumerable.Empty().ToList(), + DownloadCount = downloadCount, + PackageRegistration = new PackageRegistration + { + Owners = Enumerable.Empty().ToList(), + DownloadCount = downloadCount + }, + Created = DateTime.UtcNow.AddDays(-daysSinceCreated), + Version = "1.0.10" + }; + + package.PackageRegistration.Packages = new[] { package }; + + var viewModel = new DisplayPackageViewModel(package, package.PackageRegistration.Packages.OrderByDescending(p => new NuGetVersion(p.Version))); + + // Act + var label = viewModel.DownloadsPerDayLabel; + + // Assert + Assert.Equal("<1", label); + } + + [Theory] + [InlineData(10, 10)] + [InlineData(11, 10)] + [InlineData(14, 10)] + [InlineData(15, 10)] + public void DownloadsPerDayLabelShowsOneWhenAverageBetweenOneAndOnePointFive(int downloadCount, int daysSinceCreated) + { + // Arrange + var package = new Package + { + Dependencies = Enumerable.Empty().ToList(), + DownloadCount = downloadCount, + PackageRegistration = new PackageRegistration + { + Owners = Enumerable.Empty().ToList(), + DownloadCount = downloadCount + }, + Created = DateTime.UtcNow.AddDays(-daysSinceCreated), + Version = "1.0.10" + }; + + package.PackageRegistration.Packages = new[] { package }; + + var viewModel = new DisplayPackageViewModel(package, package.PackageRegistration.Packages.OrderByDescending(p => new NuGetVersion(p.Version))); + + // Act + var label = viewModel.DownloadsPerDayLabel; + + // Assert + Assert.Equal("1", label); + } } } \ No newline at end of file