Skip to content

Commit

Permalink
Order results by distance
Browse files Browse the repository at this point in the history
  • Loading branch information
slawosz committed Nov 27, 2023
1 parent 1934737 commit ca3edd8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/hub.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class Hub < ApplicationRecord
def self.by_local_authority(*authorities)
where("areas && ARRAY[?]::varchar[]", authorities)
result = []
authorities.each do |authority|
result << where("areas && ARRAY[?]::varchar[]", [authority]).to_a
end
result.flatten.uniq
end
end

0 comments on commit ca3edd8

Please sign in to comment.