Skip to content

Commit

Permalink
Request only necessary fields from MSW & use absHeight if min/max hei…
Browse files Browse the repository at this point in the history
…ght unavailable
  • Loading branch information
swrobel committed Dec 20, 2017
1 parent 9aff2a4 commit 7ecdf40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/msw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def site_url
end

def api_url(spot)
"http://magicseaweed.com/api/#{ENV['MSW_API_KEY']}/forecast?spot_id=#{spot.msw_id}&units=us"
"http://magicseaweed.com/api/#{ENV['MSW_API_KEY']}/forecast?spot_id=#{spot.msw_id}&units=us&fields=timestamp,solidRating,fadedRating,swell.absMinBreakingHeight,swell.absMaxBreakingHeight,swell.absHeight"
end

def for_chart
Expand All @@ -27,8 +27,8 @@ def parse_response(spot, request, responses)
end
record = unscoped.where(spot: spot, timestamp: tstamp).first_or_initialize
record.api_request = request
record.min_height = response.swell.absMinBreakingHeight
record.max_height = response.swell.absMaxBreakingHeight
record.min_height = response.swell.absMinBreakingHeight || response.swell.absHeight
record.max_height = response.swell.absMaxBreakingHeight || response.swell.absHeight
record.rating = response.solidRating
record.wind_effect = response.fadedRating
record.save! if record.rating.present?
Expand Down

0 comments on commit 7ecdf40

Please sign in to comment.