Class: TableList
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- TableList
show all
- Includes:
- DataImportHelper
- Defined in:
- app/models/rails_data/table_list.rb
Instance Method Summary
collapse
#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_xlsx ⇒ Object
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_old ⇒ Object
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_xlsx ⇒ Object
16
17
18
19
20
|
# File 'app/models/rails_data/table_list.rb', line 16
def direct_xlsx
= self..presence || self.data_list.
export = XlsxExportService.new(data_list: self.data_list, params: self.parameters, 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
|
#run ⇒ Object
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
|