Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store version and download counts. Add a script to recalculate score.
- Loading branch information
Showing
5 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
site/db/migrate/20101022130929_add_downloads_version_downloads_and_version_to_rocks.rb
This file contains 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 characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
class AddDownloadsVersionDownloadsAndVersionToRocks < ActiveRecord::Migration | |||
def self.up | |||
add_column :rocks, :downloads, :integer | |||
add_column :rocks, :version_downloads, :integer | |||
add_column :rocks, :version, :string | |||
end | |||
|
|||
def self.down | |||
remove_column :rocks, :version | |||
remove_column :rocks, :version_downloads | |||
remove_column :rocks, :downloads | |||
end | |||
end |
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
#!/usr/bin/env ruby | |||
require File.expand_path('../../config/environment', __FILE__) | |||
|
|||
Rock.find_in_batches do |clump| | |||
clump.each do |rock| | |||
rock.update_attributes( | |||
:score => Mine::Gem.new(:downloads => rock.downloads, :version_downloads => rock.version_downloads).score | |||
) | |||
end | |||
end |
This file contains 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 characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,7 +1,20 @@ | |||
#!/usr/bin/env ruby | #!/usr/bin/env ruby | ||
require File.expand_path('../../config/environment', __FILE__) | require File.expand_path('../../config/environment', __FILE__) | ||
|
|
||
Mine.all(1).each do |gem| | page = 1 | ||
rock = Rock.find_or_initialize_by_name(gem.name) | while(page) | ||
rock.update_attributes(:description => gem.info, :authors => gem.authors, :score => gem.score) | puts "Fetching page ##{page}" | ||
end | gems = Mine.all(page) | ||
gems.each do |gem| | |||
rock = Rock.find_or_initialize_by_name(gem.name) | |||
rock.update_attributes( | |||
:description => gem.info, | |||
:authors => gem.authors, | |||
:version => gem.version, | |||
:downloads => gem.downloads, | |||
:version_downloads => gem.version_downloads, | |||
:score => gem.score | |||
) | |||
end | |||
page = gems.empty? ? nil : page + 1 | |||
end |