-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix distance field #145
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,14 +116,24 @@ def geokit_finder_adapter | |
end | ||
|
||
def within(distance, options = {}) | ||
origin = extract_origin_from_options(options) | ||
units = extract_units_from_options(options) | ||
formula = extract_formula_from_options(options) | ||
|
||
options[:within] = distance | ||
|
||
# Add bounding box to speed up SQL request. | ||
bounds = formulate_bounds_from_distance( | ||
options, | ||
normalize_point_to_lat_lng(options[:origin]), | ||
options[:units] || default_units) | ||
with_latlng.where(bound_conditions(bounds)). | ||
where(distance_conditions(options)) | ||
|
||
distance_column_name = distance_sql(origin, units, formula) | ||
|
||
with_latlng | ||
.select("#{distance_column_name} AS #{self.distance_column_name}, #{table_name}.*") | ||
.where(bound_conditions(bounds)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the previous line, together with the method call receiver. |
||
.where(distance_conditions(options)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the previous line, together with the method call receiver. |
||
end | ||
alias inside within | ||
|
||
|
@@ -154,9 +164,9 @@ def by_distance(options = {}) | |
units = extract_units_from_options(options) | ||
formula = extract_formula_from_options(options) | ||
distance_column_name = distance_sql(origin, units, formula) | ||
with_latlng.order( | ||
Arel.sql(distance_column_name).send(options[:reverse] ? 'desc' : 'asc') | ||
) | ||
with_latlng | ||
.select("#{distance_column_name} AS #{self.distance_column_name}, #{table_name}.*") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the previous line, together with the method call receiver. |
||
.order(Arel.sql(distance_column_name).send(options[:reverse] ? 'desc' : 'asc')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Layout/DotPosition: Place the . on the previous line, together with the method call receiver. |
||
end | ||
|
||
def with_latlng | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/DotPosition: Place the . on the previous line, together with the method call receiver.
Metrics/LineLength: Line is too long. [93/80]