From 7cb43af04cfeaf4ee2c8dfdaa00f1d0b36899da1 Mon Sep 17 00:00:00 2001 From: anurse Date: Thu, 13 Mar 2014 10:36:40 -0700 Subject: [PATCH 1/2] Fix NuGet/NuGetGallery#1963 by adding Updates to Search Ranking at a factor of 0.5 --- .../Jobs/Scripts/SearchRanking_ByProjectType.sql | 4 ++-- .../Jobs/Scripts/SearchRanking_Overall.sql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql index ce5cb0c..cddd8c6 100644 --- a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql +++ b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql @@ -1,4 +1,4 @@ -SELECT TOP(200) Dimension_Package.PackageId, SUM(DownloadCount) 'Downloads' +SELECT TOP(200) Dimension_Package.PackageId, SUM(CASE WHEN Dimension_Operation.Operation = 'Install' THEN DownloadCount ELSE (0.5 * DownloadCount) END) 'Downloads' FROM Fact_Download INNER JOIN Dimension_Package ON Dimension_Package.Id = Fact_Download.Dimension_Package_Id INNER JOIN Dimension_Date ON Dimension_Date.Id = Fact_Download.Dimension_Date_Id @@ -7,7 +7,7 @@ INNER JOIN Dimension_Project ON Dimension_Project.Id = Fact_Download.Dimension_P WHERE Dimension_Date.[Date] >= CONVERT(DATE, DATEADD(day, -42, GETDATE())) AND Dimension_Date.[Date] < CONVERT(DATE, GETDATE()) AND Dimension_Package.PackageListed = 1 - AND Dimension_Operation.Operation = 'Install' + AND (Dimension_Operation.Operation = 'Install' OR Dimension_Operation.Operation = 'Update') AND Dimension_Project.ProjectTypes = @ProjectGuid GROUP BY Dimension_Package.PackageId ORDER BY SUM(DownloadCount) DESC diff --git a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_Overall.sql b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_Overall.sql index d439fd0..fc90775 100644 --- a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_Overall.sql +++ b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_Overall.sql @@ -1,4 +1,4 @@ -SELECT TOP(200) Dimension_Package.PackageId, SUM(DownloadCount) 'Downloads' +SELECT TOP(200) Dimension_Package.PackageId, SUM(CASE WHEN Dimension_Operation.Operation = 'Install' THEN DownloadCount ELSE (0.5 * DownloadCount) END) 'Downloads' FROM Fact_Download INNER JOIN Dimension_Package ON Dimension_Package.Id = Fact_Download.Dimension_Package_Id INNER JOIN Dimension_Date ON Dimension_Date.Id = Fact_Download.Dimension_Date_Id @@ -6,6 +6,6 @@ INNER JOIN Dimension_Operation ON Dimension_Operation.Id = Fact_Download.Dimensi WHERE Dimension_Date.[Date] >= CONVERT(DATE, DATEADD(day, -42, GETDATE())) AND Dimension_Date.[Date] < CONVERT(DATE, GETDATE()) AND Dimension_Package.PackageListed = 1 - AND Dimension_Operation.Operation = 'Install' + AND (Dimension_Operation.Operation = 'Install' OR Dimension_Operation.Operation = 'Update') GROUP BY Dimension_Package.PackageId -ORDER BY SUM(DownloadCount) DESC +ORDER BY Downloads DESC \ No newline at end of file From 5432a5fb979f32f999b6d1a0e1b14bf61b99f49e Mon Sep 17 00:00:00 2001 From: Andrew Nurse Date: Thu, 13 Mar 2014 11:00:27 -0700 Subject: [PATCH 2/2] Fixed incorrect ORDER BY --- .../Jobs/Scripts/SearchRanking_ByProjectType.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql index cddd8c6..7ed7076 100644 --- a/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql +++ b/src/NuGet.Services.Work/Jobs/Scripts/SearchRanking_ByProjectType.sql @@ -1,4 +1,4 @@ -SELECT TOP(200) Dimension_Package.PackageId, SUM(CASE WHEN Dimension_Operation.Operation = 'Install' THEN DownloadCount ELSE (0.5 * DownloadCount) END) 'Downloads' +SELECT TOP(200) Dimension_Package.PackageId, SUM(CASE WHEN Dimension_Operation.Operation = 'Install' THEN DownloadCount ELSE (0.5 * DownloadCount) END) 'Downloads' FROM Fact_Download INNER JOIN Dimension_Package ON Dimension_Package.Id = Fact_Download.Dimension_Package_Id INNER JOIN Dimension_Date ON Dimension_Date.Id = Fact_Download.Dimension_Date_Id @@ -10,4 +10,4 @@ WHERE Dimension_Date.[Date] >= CONVERT(DATE, DATEADD(day, -42, GETDATE())) AND (Dimension_Operation.Operation = 'Install' OR Dimension_Operation.Operation = 'Update') AND Dimension_Project.ProjectTypes = @ProjectGuid GROUP BY Dimension_Package.PackageId -ORDER BY SUM(DownloadCount) DESC +ORDER BY Downloads DESC