From 8e78f277356f11caa0ad19f9e4b38c8bc41ae45e Mon Sep 17 00:00:00 2001 From: Thiago Ribeiro Date: Wed, 9 Sep 2015 15:20:41 -0300 Subject: [PATCH] Fix broken tests in sniffer plugin. --- plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb | 4 ++-- plugins/sniffer/lib/sniffer_plugin/helper.rb | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb b/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb index 94da1e1..f9b619d 100644 --- a/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb +++ b/plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb @@ -38,7 +38,7 @@ class SnifferPluginMyprofileController < MyProfileController response[:enterprises] = product_category.sniffer_plugin_enterprises.enabled.visible.map do |enterprise| profile_data = filter_visible_attr_profile(enterprise) profile_data[:balloonUrl] = url_for :controller => :sniffer_plugin_myprofile, :action => :map_balloon, :id => enterprise[:id], :escape => false - profile_data[:sniffer_plugin_distance] = distance_between_profiles(@profile, enterprise) + profile_data[:sniffer_plugin_distance] = Noosfero::GeoRef.dist(@profile.lat, @profile.lng, enterprise.lat, enterprise.lng) profile_data[:suppliersProducts] = filter_visible_attr_suppliers_products( enterprise.products.sniffer_plugin_products_from_category(product_category) ) @@ -109,7 +109,7 @@ class SnifferPluginMyprofileController < MyProfileController profiles = Profile.all :conditions => {:id => products.map { |p| target_profile_id(p) }} profiles_by_id = {} profiles.each do |p| - p[:sniffer_plugin_distance] = distance_between_profiles(@profile, p) + p[:sniffer_plugin_distance] = Noosfero::GeoRef.dist(@profile.lat, @profile.lng, p.lat, p.lng) profiles_by_id[p.id] ||= p end profiles_by_id diff --git a/plugins/sniffer/lib/sniffer_plugin/helper.rb b/plugins/sniffer/lib/sniffer_plugin/helper.rb index 98fe14d..a454ece 100644 --- a/plugins/sniffer/lib/sniffer_plugin/helper.rb +++ b/plugins/sniffer/lib/sniffer_plugin/helper.rb @@ -2,13 +2,6 @@ module SnifferPlugin::Helper include Noosfero::GeoRef - def distance_between_profiles(source, target) - Math.sqrt( - (KM_LAT * ((target.lat || 0) - (source.lat || 0)))**2 + - (KM_LNG * ((target.lng || 0) - (source.lng || 0)))**2 - ) - end - def filter_visible_attr_profile(profile) filtered_profile = {} visible_attributes = [:id, :name, :lat, :lng, :sniffer_plugin_distance] -- libgit2 0.21.2