Class: Api::V1::FiresController

Inherits:
ApplicationController
  • Object
show all
Includes:
Pagy::Backend
Defined in:
app/controllers/orb_def/api/v1/fires_controller.rb

Instance Method Summary collapse

Instance Method Details

#fires_current_wind_direction_indicatorObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/orb_def/api/v1/fires_controller.rb', line 18

def fires_current_wind_direction_indicator

  wind_indicators = fires_in_bounds.map do |fire|
    current_weather = fire.weather_station.weather_readings.last
    endpoint = fire.endpoint(current_weather.wind_direction, 2)
    {
      fire: { lat: fire.latitude, lng: fire.longitude },
      wind: { lat: endpoint.lat, lng: endpoint.lng }
    }
  end

  render json: wind_indicators, status: :ok
end

#indexObject



6
7
8
9
10
# File 'app/controllers/orb_def/api/v1/fires_controller.rb', line 6

def index
  @pagy, @records = pagy(Fire.in_last_24_hours, items: 100)

  render json: { data: @records }, status: :ok, each_serializer: Api::V1::FireSerializer
end

#searchObject



12
13
14
15
16
# File 'app/controllers/orb_def/api/v1/fires_controller.rb', line 12

def search
  @pagy, @records = pagy(Fire.in_last_24_hours.in_bounds([sw_bound_point, ne_bound_point]), items: 100)

  render json: @records, status: :ok, each_serializer: Api::V1::FireSerializer
end