Skip to content

Commit

Permalink
Tweaking UpdateStatisticsJob to update PackageRegistrations condition…
Browse files Browse the repository at this point in the history
…ally
  • Loading branch information
pranavkm committed Aug 23, 2012
1 parent cfb2db1 commit e65e331
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Website/Infrastructure/Jobs/UpdateStatisticsJob.cs
Expand Up @@ -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);
Expand Down

0 comments on commit e65e331

Please sign in to comment.