Class: RefreshMaterializedViewJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- RefreshMaterializedViewJob
- Defined in:
- app/jobs/refresh_materialized_view_job.rb
Overview
Refresh a materialized view asynchronously via the delayed_job queue. If no view_name supplied, refresh all materialized views
Instance Method Summary collapse
Instance Method Details
#perform(view_name: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/jobs/refresh_materialized_view_job.rb', line 10 def perform(view_name: nil) conn = ActiveRecord::Base.connection if view_name.present? Rails.logger.info("Refreshing materialized view #{view_name}...") conn.execute("REFRESH MATERIALIZED VIEW #{view_name};") else Rails.logger.info("Refreshing all materialized views...") conn.execute("SELECT refresh_all_matierialized_views();") end end |