Class: Superset::Dashboard::WarmUpCache

Inherits:
Request
  • Object
show all
Defined in:
lib/superset/dashboard/warm_up_cache.rb

Constant Summary

Constants inherited from Request

Request::PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num

Instance Method Summary collapse

Methods inherited from Request

call, #query_params, #result, #superset_host

Methods included from Superset::Display

#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title

Constructor Details

#initialize(dashboard_id:) ⇒ WarmUpCache

Returns a new instance of WarmUpCache.



7
8
9
# File 'lib/superset/dashboard/warm_up_cache.rb', line 7

def initialize(dashboard_id:)
  @dashboard_id = dashboard_id
end

Instance Attribute Details

#dashboard_idObject (readonly)

Returns the value of attribute dashboard_id.



5
6
7
# File 'lib/superset/dashboard/warm_up_cache.rb', line 5

def dashboard_id
  @dashboard_id
end

Instance Method Details

#performObject



11
12
13
14
# File 'lib/superset/dashboard/warm_up_cache.rb', line 11

def perform
  validate_dashboard_id
  response
end

#responseObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/superset/dashboard/warm_up_cache.rb', line 16

def response
  dataset_details = fetch_dataset_details(dashboard_id)
  dataset_details.each do |dataset|
    begin
      warm_up_dataset(dataset["datasource_name"], dataset["name"])
    rescue => e
      Rollbar.error("Warm up cache failed for the dashboard #{dashboard_id.to_s} and for the dataset #{dataset["datasource_name"]} - #{e}")
    end 
  end
end

#warm_up_dataset(dataset_name, db_name) ⇒ Object



27
28
29
# File 'lib/superset/dashboard/warm_up_cache.rb', line 27

def warm_up_dataset(dataset_name, db_name)
  Superset::Dataset::WarmUpCache.new(dashboard_id: dashboard_id, table_name: dataset_name, db_name: db_name).perform
end