]> git.openstreetmap.org Git - rails.git/commitdiff
Merge branch 'master' into openstreetbugs
authorTom Hughes <tom@compton.nu>
Fri, 7 May 2010 21:29:09 +0000 (22:29 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 7 May 2010 21:29:09 +0000 (22:29 +0100)
Conflicts:
lib/osm.rb

1  2 
config/environment.rb
config/locales/en.yml
config/routes.rb
lib/osm.rb

Simple merge
Simple merge
Simple merge
diff --cc lib/osm.rb
index 1358c993af7cdeaae4709f091c12055aa40d32b4,46b90447781b23938a6cc3820403381c8ba30272..2a1ca089eb70ca681af2b7b3c2e1259d72e3de11
@@@ -498,15 -499,24 +499,34 @@@ module OS
      return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}"
    end
  
 +  # Return an SQL fragment to select a given area of the globe without using the quadtile index
 +  def self.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon, prefix = nil, without_quadtile = :false)
 +    minlat = (minlat * 10000000).round
 +    minlon = (minlon * 10000000).round
 +    maxlat = (maxlat * 10000000).round
 +    maxlon = (maxlon * 10000000).round
 +
 +    return "#{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}"
 +  end
 +
+   # Return a spam score for a chunk of text
+   def self.spam_score(text)
+     link_count = 0
+     link_size = 0
  
+     doc = Nokogiri::HTML(text)
+     if doc.content.length > 0
+       doc.xpath("//a").each do |link|
+         link_count += 1
+         link_size += link.content.length
+       end
+       link_proportion = link_size.to_f / doc.content.length.to_f
+     else
+       link_proportion = 0
+     end
+     return [link_proportion - 0.2, 0.0].max * 200 + link_count * 20
+   end
  end