Class: AnalyticsSqlAuditLog
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- AnalyticsSqlAuditLog
- Defined in:
- app/models/analytics_sql_audit_log.rb
Overview
Audit trail for SQL tool calls executed by the AI assistant.
Stores normalized SQL metadata, execution outcome, and safety blocks.
== Schema Information
Table name: analytics_sql_audit_logs
Database name: primary
id :bigint not null, primary key
duration_ms :integer default(0), not null
error_message :text
referenced_objects :jsonb not null
returned_column_count :integer default(0), not null
returned_row_count :integer default(0), not null
role :string not null
service_key :string not null
sql_fingerprint :string not null
sql_query :text not null
status :string not null
tool_name :string not null
created_at :datetime not null
updated_at :datetime not null
assistant_conversation_id :bigint
user_id :bigint
Indexes
idx_sql_audit_logs_on_conversation_id (assistant_conversation_id)
idx_sql_audit_logs_service_status_created (service_key,status,created_at)
index_analytics_sql_audit_logs_on_created_at (created_at)
index_analytics_sql_audit_logs_on_sql_fingerprint (sql_fingerprint)
index_analytics_sql_audit_logs_on_status (status)
index_analytics_sql_audit_logs_on_user_id (user_id)
Constant Summary
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
Belongs to collapse
Class Method Summary collapse
-
.blocked ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are blocked.
-
.errored ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are errored.
-
.recent ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are recent.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#role ⇒ String
52 |
# File 'app/models/analytics_sql_audit_log.rb', line 52 validates :service_key, :tool_name, :role, :status, :sql_fingerprint, presence: true |
#service_key ⇒ String
52 |
# File 'app/models/analytics_sql_audit_log.rb', line 52 validates :service_key, :tool_name, :role, :status, :sql_fingerprint, presence: true |
#sql_fingerprint ⇒ String
52 |
# File 'app/models/analytics_sql_audit_log.rb', line 52 validates :service_key, :tool_name, :role, :status, :sql_fingerprint, presence: true |
#status ⇒ String
52 |
# File 'app/models/analytics_sql_audit_log.rb', line 52 validates :service_key, :tool_name, :role, :status, :sql_fingerprint, presence: true |
#tool_name ⇒ String
52 |
# File 'app/models/analytics_sql_audit_log.rb', line 52 validates :service_key, :tool_name, :role, :status, :sql_fingerprint, presence: true |
Class Method Details
.blocked ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are blocked. Active Record Scope
55 |
# File 'app/models/analytics_sql_audit_log.rb', line 55 scope :blocked, -> { where(status: 'blocked') } |
.errored ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are errored. Active Record Scope
56 |
# File 'app/models/analytics_sql_audit_log.rb', line 56 scope :errored, -> { where(status: 'error') } |
.recent ⇒ ActiveRecord::Relation<AnalyticsSqlAuditLog>
A relation of AnalyticsSqlAuditLogs that are recent. Active Record Scope
54 |
# File 'app/models/analytics_sql_audit_log.rb', line 54 scope :recent, -> { order(created_at: :desc) } |
Instance Method Details
#assistant_conversation ⇒ AssistantConversation?
38 |
# File 'app/models/analytics_sql_audit_log.rb', line 38 belongs_to :assistant_conversation, optional: true |
#user ⇒ Party?
40 |
# File 'app/models/analytics_sql_audit_log.rb', line 40 belongs_to :user, class_name: 'Party', optional: true |