Class: TableList

Inherits:
ApplicationRecord
  • Object
show all
Includes:
DataImportHelper
Defined in:
app/models/rails_data/table_list.rb

Instance Method Summary collapse

Methods included from DataImportHelper

#import_columns, #import_to_table_list, #migrate

Instance Method Details

#cached_run(_timestamp = nil) ⇒ Object



27
28
29
30
31
32
# File 'app/models/rails_data/table_list.rb', line 27

def cached_run(_timestamp = nil)
  unless self.timestamp.present? && self.timestamp == _timestamp.to_s
    self.timestamp = _timestamp
    run
  end
end

#cached_xlsxObject



22
23
24
25
# File 'app/models/rails_data/table_list.rb', line 22

def cached_xlsx
  export = XlsxExportService.new(table_list: self)
  export.cached_xlsx
end

#clear_oldObject



34
35
36
37
38
39
40
# File 'app/models/rails_data/table_list.rb', line 34

def clear_old
  self.done = false
  self.class.transaction do
    self.save!
    table_items.delete_all
  end
end

#direct_xlsxObject



16
17
18
19
20
# File 'app/models/rails_data/table_list.rb', line 16

def direct_xlsx
  _headers = self.headers.presence || self.data_list.headers
  export = XlsxExportService.new(data_list: self.data_list, params: self.parameters, headers: _headers)
  export.direct_xlsx
end

#file_name(format) ⇒ Object



42
43
44
45
# File 'app/models/rails_data/table_list.rb', line 42

def file_name(format)
  name = self.id || 'example'
  "#{name}.#{format}"
end

#runObject



10
11
12
13
14
# File 'app/models/rails_data/table_list.rb', line 10

def run
  clear_old
  export = DataCacheService.new(self)
  export.cache_table
end