Skip to content

Commit

Permalink
remove polygon support for subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan committed Dec 4, 2024
1 parent 2abcad6 commit d750a06
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions app/models/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,17 @@ def limit_by_location(vacancies, location, radius_in_miles)
if query.blank? || LocationQuery::NATIONWIDE_LOCATIONS.include?(query)
vacancies
else
#TODO: add polygon support? 'within?' function for polygons doesn't support distance like ST_Within function does
radius_in_metres = convert_miles_to_metres radius_in_miles
LocationPolygon.with_name(query)
# polygon = nil
# if polygon.present?
# vacancies.select { |v| v.organisations.map(&:geopoint).any? { |point| polygon.area.contains?(point) } }
# # vacancies.select {|v| v.organisations.map(&:geopoint).any? { |point| polygon.area.intersects? point.buffer(radius_in_metres) } }
# else
coordinates = Geocoding.new(query).coordinates
search_point = RGeo::Geographic.spherical_factory.point(coordinates.second, coordinates.first)
vacancies.select { |v| v.organisations.map(&:geopoint).any? { |point| search_point.distance(point) < radius_in_metres } }
# end
end
end
end

def handle_location(scope, criteria)
if criteria.key?(:location)
# [scope.search_by_location(criteria[:location], criteria[:radius]), criteria.except(:location, :radius)]
[self.class.limit_by_location(scope, criteria[:location], criteria[:radius]), criteria.except(:location, :radius)]

else
Expand Down

0 comments on commit d750a06

Please sign in to comment.