Skip to content

Commit

Permalink
If BER in origin or destination in any segment use jetradar chain ins…
Browse files Browse the repository at this point in the history
…tead of skyscanner chain
  • Loading branch information
DeLaGuardo committed Sep 26, 2014
1 parent 96e334b commit 9a64dd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/models/nano_api/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def search options = {}
NanoApi.client.search(search_params, options)
end

def has_place? code
segments.flat_map(&:places).any? { |place| place.iata == code }
end

def params
present_attributes.merge(
segments: segments.map(&:params),
Expand Down
6 changes: 3 additions & 3 deletions lib/nano_api/backends/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create
domain: default_nano_domain
}

search_result = @search.search(search_options)
search_result = @search.search(search_options(@search))

if search_result.present?
if search_result.is_a?(String)
Expand Down Expand Up @@ -83,8 +83,8 @@ def get_search_by_id
end
end

def search_options
simple_chain = if marker == default_marker && CmsEngine::DomainConfig.current.alternate_chain
def search_options search
simple_chain = if marker == default_marker && CmsEngine::DomainConfig.current.alternate_chain && !search.has_place?('BER')
Settings.nano_api.alternate_chain
end
{
Expand Down

0 comments on commit 9a64dd2

Please sign in to comment.