-
-
Save joelmoss/405292 to your computer and use it in GitHub Desktop.
Revisions
-
qrush revised this gist
Mar 17, 2010 . 1 changed file with 5 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,8 +9,8 @@ downloads:today => sorted set for downloads from today downloads:rubygem:rails => counter for all rails downloads downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads downloads:rubygem_daily:rails => daily download hash for this rubygem downloads:version_daily:rails-2.3.5 => daily download hash for this version Daily download hash format: { @@ -40,12 +40,7 @@ keys.each do |key| version = Version.find_by_full_name(key) downloads = ZSCORE downloads:yesterday key HINCRBY downloads:version_daily:#{version.full_name} Date.today downloads HINCRBY downloads:rubygem_daily:#{version.rubygem.name} Date.today downloads end -
qrush revised this gist
Feb 6, 2010 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,12 +32,13 @@ ZINCRBY downloads:today 1 bundler-0.9.2 on a daily cron --------------- RENAME downloads:today downloads:yesterday keys = ZRANGE downloads:yesterday 0 -1 keys.each do |key| version = Version.find_by_full_name(key) downloads = ZSCORE downloads:yesterday key version_downloads = JSON.parse( GET downloads:version_daily:#{version.full_name} ) version_downloads[Date.today] = downloads @@ -48,5 +49,3 @@ keys.each do |key| SET downloads:rubygem_daily:#{version.rubygem.name} JSON.dump( rubygem_downloads ) end -
qrush revised this gist
Feb 6, 2010 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ ZINCRBY downloads:today 1 bundler-0.9.2 on a daily cron --------------- keys = ZRANGE env:downloads:today 0 -1 keys.each do |key| @@ -47,4 +47,6 @@ keys.each do |key| rubygem_downloads[Date.today] += downloads SET downloads:rubygem_daily:#{version.rubygem.name} JSON.dump( rubygem_downloads ) end DEL env:downloads:today -
qrush revised this gist
Feb 6, 2010 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,10 +41,10 @@ keys.each do |key| version_downloads = JSON.parse( GET downloads:version_daily:#{version.full_name} ) version_downloads[Date.today] = downloads SET downloads:version_daily:#{version.full_name} JSON.dump( version_downloads ) rubygem_downloads = JSON.parse( GET downloads:rubygem_daily:#{version.rubygem.name} ) rubygem_downloads[Date.today] += downloads SET downloads:rubygem_daily:#{version.rubygem.name} JSON.dump( rubygem_downloads ) end -
qrush revised this gist
Feb 6, 2010 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,15 @@ gemcutter => redis downloads spec keys ---- downloads => global counter for all gem downloads downloads:today => sorted set for downloads from today downloads:rubygem:rails => counter for all rails downloads downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads downloads:rubygem_daily:rails => JSON daily download hash for this rubygem downloads:version_daily:rails-2.3.5 => JSON daily download hash for this version Daily download hash format: { '2010-02-01' : 134, '2010-02-02' : 289, @@ -24,10 +24,10 @@ on a download Let's say /gems/bundler-0.9.2.gem was hit... INCR downloads INCR downloads:rubygem:bundler INCR downloads:version:bundler-0.9.2 ZINCRBY downloads:today 1 bundler-0.9.2 on a daily cron --------------- @@ -37,14 +37,14 @@ keys = ZRANGE env:downloads today 0 -1 keys.each do |key| version = Version.find_by_full_name(key) downloads = ZSCORE downloads:today key version_downloads = JSON.parse( GET downloads:version_daily:#{version.full_name} ) version_downloads[Date.today] = downloads SET JSON.dump( downloads:version_daily:#{version.full_name} ) rubygem_downloads = JSON.parse( GET downloads:rubygem_daily:#{version.rubygem.name} ) rubygem_downloads[Date.today] += downloads SET JSON.dump( downloads:rubygem_daily:#{version.rubygem.name} ) end -
qrush created this gist
Feb 6, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ gemcutter => redis downloads spec ================================= keys ---- env:downloads => global counter for all gem downloads env:downloads:today => sorted set for downloads from today env:downloads:rubygem:rails => counter for all rails downloads env:downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads env:downloads:rubygem_daily:rails => JSON daily download hash for this rubygem env:downloads:version_daily:rails-2.3.5 => JSON daily download hash for this version Daily download hash: { '2010-02-01' : 134, '2010-02-02' : 289, ... } on a download ------------- Let's say /gems/bundler-0.9.2.gem was hit... INCR env:downloads INCR env:downloads:rubygem:bundler INCR env:downloads:version:bundler-0.9.2 ZINCRBY env:downloads:today 1 bundler-0.9.2 on a daily cron --------------- keys = ZRANGE env:downloads today 0 -1 keys.each do |key| version = Version.find_by_full_name(key) downloads = ZSCORE env:downloads:today key version_downloads = JSON.parse( GET env:downloads:version_daily:#{version.full_name} ) version_downloads[Date.today] = downloads SET JSON.dump( env:downloads:version_daily:#{version.full_name} ) rubygem_downloads = JSON.parse( GET env:downloads:rubygem_daily:#{version.rubygem.name} ) rubygem_downloads[Date.today] += downloads SET JSON.dump( env:downloads:rubygem_daily:#{version.rubygem.name} ) end