Class: MatViews::RefreshViewJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- MatViews::RefreshViewJob
- Defined in:
- app/jobs/mat_views/refresh_view_job.rb
Overview
ActiveJob that handles ‘REFRESH MATERIALIZED VIEW` for a given MatViewDefinition.
The job mirrors CreateViewJob‘s lifecycle: it measures duration and persists state in MatViewRun.
The actual refresh implementation is delegated based on ‘definition.refresh_strategy`:
-
‘“concurrent”` → Services::ConcurrentRefresh
-
‘“swap”` → Services::SwapRefresh
-
otherwise → Services::RegularRefresh
Row count reporting can be controlled via ‘row_count_strategy`:
-
‘:estimated` (default) - fast, approximate via reltuples
-
‘:exact` - accurate `COUNT(*)`
-
‘nil` - skip counting
Instance Method Summary collapse
-
#perform(mat_view_definition_id, row_count_strategy_arg = nil) ⇒ Hash
Perform the refresh job for the given materialised view definition.
Instance Method Details
#perform(mat_view_definition_id, row_count_strategy_arg = nil) ⇒ Hash
Perform the refresh job for the given materialised view definition.
66 67 68 69 70 71 |
# File 'app/jobs/mat_views/refresh_view_job.rb', line 66 def perform(mat_view_definition_id, row_count_strategy_arg = nil) definition = MatViews::MatViewDefinition.find(mat_view_definition_id) record_run(definition, :refresh) do service(definition).new(definition, row_count_strategy: normalize_strategy(row_count_strategy_arg)).call end end |