From c78c8cd7a80cc90157c323b34685d4055c832335 Mon Sep 17 00:00:00 2001 From: Sai Emrys Date: Wed, 24 Mar 2010 13:44:30 -0700 Subject: [PATCH] fix site#new_total_rank, scraping:google --- app/models/site.rb | 20 ++++++++++---------- lib/tasks/scraping.rake | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 4069d3c..5bd6378 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -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 diff --git a/lib/tasks/scraping.rake b/lib/tasks/scraping.rake index efe217b..18f4491 100644 --- a/lib/tasks/scraping.rake +++ b/lib/tasks/scraping.rake @@ -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