Class: MatViews::MatViewRun
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- MatViews::MatViewRun
- Defined in:
- app/models/mat_views/mat_view_run.rb
Overview
ActiveRecord model that tracks the lifecycle of runs for materialised views.
Each record corresponds to a single attempt to mutate a materialised view from a MatViewDefinition, storing its status, timing, and any associated error or metadata.
This model provides an auditable history of view provisioning across environments, useful for telemetry, dashboards, and debugging.
Instance Attribute Summary collapse
-
#operation ⇒ Symbol
readonly
One of: -
:create- initial creation of the materialised view -:refresh- refreshing an existing view -:drop- dropping the materialised view. -
#status ⇒ Object
readonly
Validations.
Instance Method Summary collapse
-
#create_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope create runs All runs with ‘operation: :create`.
-
#drop_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope drop runs All runs with ‘operation: :drop`.
-
#mat_view_definition ⇒ MatViews::MatViewDefinition
The definition this run belongs to.
-
#refresh_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope refresh runs All runs with ‘operation: :refresh`.
-
#row_count_after ⇒ Integer?
row count after the operation, if applicable.
-
#row_count_before ⇒ Integer?
row count before the operation, if applicable.
Methods included from MatViewsI18n
hint_for, human_enum_name, human_enum_options, human_name, placeholder_for
Instance Attribute Details
#operation ⇒ Symbol (readonly)
Returns One of:
-
:create- initial creation of the materialised view -
:refresh- refreshing an existing view -
:drop- dropping the materialised view.
65 66 67 68 69 |
# File 'app/models/mat_views/mat_view_run.rb', line 65 enum :operation, { create: 0, refresh: 1, drop: 2 }, prefix: :operation |
#status ⇒ Object (readonly)
Validations
Ensures that a status is always present.
52 53 54 55 56 |
# File 'app/models/mat_views/mat_view_run.rb', line 52 enum :status, { running: 0, success: 1, failed: 2 }, prefix: :status |
Instance Method Details
#create_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope create runs All runs with ‘operation: :create`.
81 |
# File 'app/models/mat_views/mat_view_run.rb', line 81 scope :create_runs, -> { where(operation: :create) } |
#drop_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope drop runs All runs with ‘operation: :drop`.
93 |
# File 'app/models/mat_views/mat_view_run.rb', line 93 scope :drop_runs, -> { where(operation: :drop) } |
#mat_view_definition ⇒ MatViews::MatViewDefinition
The definition this run belongs to.
41 |
# File 'app/models/mat_views/mat_view_run.rb', line 41 belongs_to :mat_view_definition, class_name: 'MatViews::MatViewDefinition' |
#refresh_runs ⇒ ActiveRecord::Relation<MatViews::MatViewRun>
Scope refresh runs All runs with ‘operation: :refresh`.
87 |
# File 'app/models/mat_views/mat_view_run.rb', line 87 scope :refresh_runs, -> { where(operation: :refresh) } |
#row_count_after ⇒ Integer?
row count after the operation, if applicable
103 104 105 |
# File 'app/models/mat_views/mat_view_run.rb', line 103 def row_count_after .dig('response', 'row_count_after') end |
#row_count_before ⇒ Integer?
row count before the operation, if applicable
97 98 99 |
# File 'app/models/mat_views/mat_view_run.rb', line 97 def row_count_before .dig('response', 'row_count_before') end |