Skip to content

Commit

Permalink
fix site#new_total_rank, scraping:google
Browse files Browse the repository at this point in the history
  • Loading branch information
saizai committed Mar 24, 2010
1 parent 29c117e commit c78c8cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions app/models/site.rb
Expand Up @@ -56,24 +56,24 @@ def self.get offset, batch_size = 500

def new_total_rank
total, weights = 0, 0
if site.google_rank
total += GOOGLE_WEIGHT * (site.google_rank / 10.0)
if google_rank
total += GOOGLE_WEIGHT * (google_rank / 10.0)
weights += GOOGLE_WEIGHT
end
if site.technorati_rank
total += TECHNORATI_WEIGHT * (101 - site.technorati_rank) / 100.0
if technorati_rank
total += TECHNORATI_WEIGHT * (101 - technorati_rank) / 100.0
weights += TECHNORATI_WEIGHT
end
if site.quantcast_rank
total += QUANTCAST_WEIGHT * (1000001 - site.quantcast_rank) / 1000000.0
if quantcast_rank
total += QUANTCAST_WEIGHT * (1000001 - quantcast_rank) / 1000000.0
weights += QUANTCAST_WEIGHT
end
if site.bloglines_rank
total += BLOGLINES_WEIGHT * (1001 - site.bloglines_rank) / 1000.0
if bloglines_rank
total += BLOGLINES_WEIGHT * (1001 - bloglines_rank) / 1000.0
weights += BLOGLINES_WEIGHT
end
if site.alexa_rank
total += ALEXA_WEIGHT * (1000001 - site.alexa_rank) / 1000000.0
if alexa_rank
total += ALEXA_WEIGHT * (1000001 - alexa_rank) / 1000000.0
weights += ALEXA_WEIGHT
end
weights > 0 ? total / weights : nil
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/scraping.rake
Expand Up @@ -57,7 +57,7 @@ namespace :scraping do
with_lock do
g = Google::PageRank.new(nil)

Site.find_each :conditions => "google_rank IS NOT NULL" do |s|
Site.find_each :conditions => "google_rank IS NULL" do |s|
s.update_attribute :google_rank, g.page_rank(s.url)
end
end
Expand Down

0 comments on commit c78c8cd

Please sign in to comment.