Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modifying aggregate stats sql to update LastUpdatedDate when updating

download count
  • Loading branch information...
commit 045465ebf7836bc42cd1bb53ff74f343c84f93d0 1 parent 11bf2ee
Pranav K pranavkm authored
9 Website/Infrastructure/AggregateStatistics.sql
View
@@ -1,7 +1,10 @@
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AggregateStatistics]') AND type in (N'P', N'PC'))
+IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AggregateStatistics]') AND type in (N'P', N'PC'))
BEGIN
+ Drop procedure [dbo].[AggregateStatistics]
+END
+GO
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE [dbo].[AggregateStatistics]
AS
@@ -38,7 +41,8 @@ AS
BEGIN TRANSACTION
UPDATE Packages
- SET Packages.DownloadCount = Packages.DownloadCount + stats.DownloadCount
+ SET Packages.DownloadCount = Packages.DownloadCount + stats.DownloadCount,
+ Packages.LastUpdated = GetUtcDate()
OUTPUT inserted.PackageRegistrationKey INTO @AffectedPackages
FROM Packages
INNER JOIN @DownloadStats stats ON Packages.[Key] = stats.PackageKey
@@ -59,5 +63,4 @@ AS
COMMIT TRANSACTION
'
-END
GO
2  Website/Infrastructure/Lucene/LuceneIndexingService.cs
View
@@ -88,7 +88,7 @@ private static void AddPackages(List<PackageIndexEntity> packages, bool creating
{
if (!creatingIndex)
{
- // If this is not the first time we're creating the index, clear clear any package registrations for packages we are going to updating.
+ // If this is not the first time we're creating the index, clear any package registrations for packages we are going to updating.
var packagesToDelete = from packageRegistrationKey in packages.Select(p => p.PackageRegistrationKey).Distinct()
select new Term("PackageRegistrationKey", packageRegistrationKey.ToString(CultureInfo.InvariantCulture));
indexWriter.DeleteDocuments(packagesToDelete.ToArray());
24 Website/Migrations/201209181743161_AggregateStatsSp_ReduxLastUpdate.Designer.cs
View
@@ -0,0 +1,24 @@
+// <auto-generated />
+namespace NuGetGallery.Migrations
+{
+ using System.Data.Entity.Migrations;
+ using System.Data.Entity.Migrations.Infrastructure;
+
+ public sealed partial class AggregateStatsSp_ReduxLastUpdate : IMigrationMetadata
+ {
+ string IMigrationMetadata.Id
+ {
+ get { return "201209181743161_AggregateStatsSp_ReduxLastUpdate"; }
+ }
+
+ string IMigrationMetadata.Source
+ {
+ get { return null; }
+ }
+
+ string IMigrationMetadata.Target
+ {
+ get { return "H4sIAAAAAAAEAO0923LjupHvW5V/UOlps1WxPLPJ1MkpOykfz8yJk7nVaCb76KIlWMM9FKmQ1IydX8tDPml/YQlecekGGiRISXP84rIAsNFoNBqNRjf6//7174s/P2yj2VeWZmESX86fnZ3PZyxeJesw3lzO9/n9736Y//lPv/mPi1fr7cPs702757xd8WWcXc6/5Pnux8UiW31h2yA724arNMmS+/xslWwXwTpZPD8//2Hx7HzBChDzAtZsdvFxH+fhlpU/ip/XSbxiu3wfRG+TNYuyuryoWZZQZ++CLct2wYpdzt/tf2b5z0EUsfRxPruKwqDAYcmie0eEzv/IEZq3XRWdvSqQyh8/Pe5Y2eHl/HqfBjlbv2ZsLTYsmv6NPUoFRdGHNNmxNH/8yO7rz4tG89lC/nChftl+J37Ecbic38T5fz+fz97toyi4i4qC+yDK2Hy2e/HjMk9S9jOLWYnghyDPWVrMy82alWOoafHj7gWNHH9cnD/n5FgEcZzkQV5Msoa5gif/2yC6zNOCX+az1+EDW79h8Sb/0iL7NnhoSop/57PPcViwV/FRnu6ZOLjqt9Lpu+BruCnxUbp/G8TBpmDH+ewji8oG2ZdwV3HCmTBvt13D12my/ZhE8ry29bfLZJ+u+JASQ6NPQbphOR3ND8Hql+JLO5pdQxjNpt6IZtsIQvNi0fG3kes/Zyx9YncFz6tdKKD68z5cA5iaQbzaBmF0tV6nLMvGXzlK558LoR7fh+mWrQ+Kx1+C7AufwSz7lqTrybtvOuZoXEWbJA3zL9v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9RRuQSijXeiQI6POEmsbpJ9BwB9pyucSNpqf8RodUScAni6ZU/DllVdIMOyx7mXFFPDrJuTDnsauK5xI3mGvREASEmCEsHiJOWTEJruDydH8UYG2LsHJwXBG2igLmHQ2NEkd+OQQ3VHIVLF6MVyksTR/Scw7dKUc23QwNUzlJwRzusQa8uyeYhwiiHNN0BAFkJ00iGabqotSqEl3Zp/3VA9yIIp40YiCT7/DundBjH7tESw3wUS9WRjIrbxlWXMAmFMOTcq+XBOcrzY8rNrjEwgLf1XW3exqCw8dUHxU0vzdbH4uI/5yyvVr5csCzcdCJ68LGYr6RanbcNf/WpukxSMmibKmw9vWR6sgzy4SvPwPljlRfWKZVlpdPx7EO1Li8YdW9/E7/f5bp8XQ2bbu0jSPvmllKn/i4WG88X78pWyzMcQCjRD/ljN+/infRitW7xfAw9WICD4bVf9EhGfSz7pbPPYQnqXxERANfnaS7pPbLuL+Ive7+Nl8JXhuNlpKFPs4mUYbAodWKRgVdI8wRXwJ+W6LooOxC+6/oqfBbuutw9/+n/7fCqPtBgBAA=="; }
+ }
+ }
+}
12 Website/Migrations/201209181743161_AggregateStatsSp_ReduxLastUpdate.cs
View
@@ -0,0 +1,12 @@
+namespace NuGetGallery.Migrations
+{
+ using System.Data.Entity.Migrations;
+
+ public partial class AggregateStatsSp_ReduxLastUpdate: SqlResourceMigration
+ {
+ public AggregateStatsSp_ReduxLastUpdate()
+ : base("NuGetGallery.Infrastructure.AggregateStatistics.sql")
+ {
+ }
+ }
+}
4 Website/Website.csproj
View
@@ -391,6 +391,10 @@
<Compile Include="Migrations\201208302051344_CreateAggregateStatisticsSP.Designer.cs">
<DependentUpon>201208302051344_CreateAggregateStatisticsSP.cs</DependentUpon>
</Compile>
+ <Compile Include="Migrations\201209181743161_AggregateStatsSp_ReduxLastUpdate.cs" />
+ <Compile Include="Migrations\201209181743161_AggregateStatsSp_ReduxLastUpdate.Designer.cs">
+ <DependentUpon>201209181743161_AggregateStatsSp_ReduxLastUpdate.cs</DependentUpon>
+ </Compile>
<Compile Include="Migrations\MigrationsConfiguration.cs" />
<Compile Include="Migrations\SqlResourceMigration.cs" />
<Compile Include="PackageCurators\IAutomaticPackageCurator.cs" />
Please sign in to comment.
Something went wrong with that request. Please try again.