Add pagination to alerts index

This commit is contained in:
2025-10-08 00:50:00 -07:00
parent adcaf46d33
commit d43483a7ad
5 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
class Api::V1::BaseController < ApplicationController
DEFAULT_PAGE_SIZE = 10
private
def per_page
(params[:per_page].presence || DEFAULT_PAGE_SIZE).to_i
end
def page
(params[:page].presence || 1).to_i
end
end

View File

@@ -3,7 +3,7 @@ module Api::V1::Parks
before_action :set_park
def index
render json: @park.alerts
render json: @park.alerts.limit(per_page).offset((page - 1) * per_page)
end
end
end