Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Tweaking UpdateStatisticsJob to update PackageRegistrations conditionally #581

Closed
wants to merge 1 commit into from

4 participants

@pranavkm
Collaborator

No description provided.

@akoeplinger

While you're at it, could you please also fix the casing problem of the script (DownLoadCount -> DownloadCount) as described here: #524 ?

@jeffhandley jeffhandley was assigned
@jeffhandley

@akoeplinger This is now handled here: 7373a5b0ab4c564105cbfd4c067476c1bfb33c37

@jeffhandley jeffhandley closed this
@jeffhandley

Strike that... here: 08211b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 11 deletions.
  1. +14 −11 Website/Infrastructure/Jobs/UpdateStatisticsJob.cs
View
25 Website/Infrastructure/Jobs/UpdateStatisticsJob.cs
@@ -66,20 +66,23 @@ UPDATE p
FROM Packages p INNER JOIN @DownloadStats stats
ON p.[Key] = stats.PackageKey
+ IF @@ROWCOUNT > 0
+ BEGIN
+ UPDATE pr
+ SET pr.DownLoadCount = totals.DownloadCount
+ FROM PackageRegistrations pr INNER JOIN
+ (
+ SELECT PackageRegistrationKey, DownloadCount = SUM(DownloadCount)
+ FROM Packages
+ GROUP BY PackageRegistrationKey
+ ) as totals
+ ON pr.[Key] = totals.PackageRegistrationKey
+ END
+
UPDATE GallerySettings
SET DownloadStatsLastAggregatedId = @mostRecentStatisticsId
-COMMIT TRANSACTION
-
-UPDATE pr
-SET pr.DownLoadCount = totals.DownloadCount
-FROM PackageRegistrations pr INNER JOIN
-(
- SELECT PackageRegistrationKey, DownloadCount = SUM(DownloadCount)
- FROM Packages
- GROUP BY PackageRegistrationKey
-) as totals
-ON pr.[Key] = totals.PackageRegistrationKey";
+COMMIT TRANSACTION";
using (var context = _contextThunk())
{
context.Database.ExecuteSqlCommand(sql);
Something went wrong with that request. Please try again.