mirror of
https://github.com/we-promise/sure.git
synced 2026-05-10 22:25:00 +00:00
feat(api): expose rule run history (#1646)
* feat(api): expose rule run history * fix(api): address rule run review * fix(api): complete rule run review * test(api): cover unauthenticated rule run show * test(api): align rule run api key helper * Small Sonnet nit-pick --------- Co-authored-by: Juan José Mata <jjmata@jjmata.com>
This commit is contained in:
@@ -216,6 +216,28 @@ class Api::V1::BaseController < ApplicationController
|
||||
value.to_s.match?(UUID_PATTERN)
|
||||
end
|
||||
|
||||
def safe_page_param
|
||||
page = params[:page].to_i
|
||||
page > 0 ? page : 1
|
||||
end
|
||||
|
||||
def safe_per_page_param
|
||||
per_page = params[:per_page].to_i
|
||||
case per_page
|
||||
when 1..100 then per_page
|
||||
when (101..) then 100
|
||||
else 25
|
||||
end
|
||||
end
|
||||
|
||||
def render_validation_error(message)
|
||||
render_json({
|
||||
error: "validation_failed",
|
||||
message: message,
|
||||
errors: [ message ]
|
||||
}, status: :unprocessable_entity)
|
||||
end
|
||||
|
||||
# Error handlers
|
||||
def handle_not_found(exception)
|
||||
Rails.logger.warn "API Record Not Found: #{exception.message}"
|
||||
|
||||
Reference in New Issue
Block a user