Add stats endpoint
This commit is contained in:
9
app/controllers/api/v1/stats_controller.rb
Normal file
9
app/controllers/api/v1/stats_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module Api::V1
|
||||
class StatsController < BaseController
|
||||
def index
|
||||
@park_count = Park.count
|
||||
@alert_count = Alert.count
|
||||
@park_with_most_alerts = Alert.group(:park_code).count.max
|
||||
end
|
||||
end
|
||||
end
|
||||
6
app/views/api/v1/stats/index.json.jbuilder
Normal file
6
app/views/api/v1/stats/index.json.jbuilder
Normal file
@@ -0,0 +1,6 @@
|
||||
json.park_count @park_count
|
||||
json.alert_count @alert_count
|
||||
json.most_alerts do
|
||||
json.park_code @park_with_most_alerts[0]
|
||||
json.alert_count @park_with_most_alerts[1]
|
||||
end
|
||||
Reference in New Issue
Block a user