feat: add pagination support for audit logs API (#6843)

Add pagination support for audit logs API
This commit is contained in:
Vishnu Narayanan
2023-04-10 21:07:01 +05:30
committed by GitHub
parent d49989ace1
commit ad75a79135
3 changed files with 15 additions and 7 deletions

View File

@@ -3,8 +3,16 @@ class Api::V1::Accounts::AuditLogsController < Api::V1::Accounts::BaseController
before_action :check_admin_authorization?
before_action :fetch_audit
RESULTS_PER_PAGE = 15
def show
render json: @audit_logs
@audit_logs = @audit_logs.page(params[:page]).per(RESULTS_PER_PAGE)
render json: {
audit_logs: @audit_logs,
current_page: @audit_logs.current_page,
per_page: RESULTS_PER_PAGE,
total_entries: @audit_logs.total_count
}
end
private