Class: CommandTower::Services::Audit::Events::List
- Inherits:
-
CommandTower::Services::ApplicationService
- Object
- CommandTower::ServiceBase
- CommandTower::Services::ApplicationService
- CommandTower::Services::Audit::Events::List
- Defined in:
- app/services/command_tower/services/audit/events.rb
Constant Summary collapse
- VIEWER_SCOPES =
%i[user admin].freeze
Constants inherited from CommandTower::ServiceBase
CommandTower::ServiceBase::ON_ARGUMENT_VALIDATION
Instance Method Summary collapse
Methods inherited from CommandTower::Services::ApplicationService
Methods included from Transactional
#fail_transaction!, #transaction
Methods inherited from CommandTower::ServiceBase
#command_tower_lifecycle, inherited, #internal_validate, #service_lifecycle_error_codes, #service_lifecycle_log_level, #validate!
Methods included from Logging::LifecycleDeclaration
Methods included from Execution::ContextAccess
#audit, #execution_context, #log_debug, #log_error, #log_info, #log_warn, #publish_event
Methods included from ArgumentValidation
Methods included from CommandTower::ServiceLogging
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/command_tower/services/audit/events.rb', line 24 def call if user_scope? && affected_user_id.nil? return context.fail!(application_error: CommandTower::Errors::InternalError.new) end relation = CommandTower::Audit::Event.order(occurred_at: :desc, id: :desc) relation = apply_viewer_scope(relation) relation = apply_admin_scope(relation) relation = apply_present_filters(relation) context.events = relation.limit(limit).offset(offset).to_a context.pagination = { limit:, offset:, total_count: relation.count } end |