Class: Purview::Tables::BaseSyncable
- Inherits:
-
Base
show all
- Defined in:
- lib/purview/tables/base_syncable.rb
Direct Known Subclasses
Raw
Instance Attribute Summary
Attributes inherited from Base
#columns, #database, #indices, #name
Instance Method Summary
collapse
Methods inherited from Base
#column_names, #columns_by_name, #columns_by_source_name, #initialize
#logger, #logger_opts, #logger_type, #with_context_logging
#blank?, #coalesced, #filter_blank_values, #filter_nil_values, #present?, #timestamp, #with_timestamp, #zero?
Instance Method Details
#created_timestamp_column ⇒ Object
#created_timestamp_index ⇒ Object
8
9
10
|
# File 'lib/purview/tables/base_syncable.rb', line 8
def created_timestamp_index
Purview::Indices::Simple.new(created_timestamp_column)
end
|
#id_column ⇒ Object
12
13
14
|
# File 'lib/purview/tables/base_syncable.rb', line 12
def id_column
column_from_opts_of_type(Purview::Columns::Id) or raise %{Must specify a column of type: "#{Purview::Columns::Id}"}
end
|
#sync(connection, window) ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/purview/tables/base_syncable.rb', line 16
def sync(connection, window)
raw_data = puller.pull(window)
parser.validate(raw_data)
parsed_data = parser.parse(raw_data)
loader.load(
connection,
parsed_data,
window
)
end
|
#temporary_name ⇒ Object
27
28
29
|
# File 'lib/purview/tables/base_syncable.rb', line 27
def temporary_name
"#{name}_#{timestamp.to_i}"
end
|
#updated_timestamp_column ⇒ Object
#updated_timestamp_index ⇒ Object
35
36
37
|
# File 'lib/purview/tables/base_syncable.rb', line 35
def updated_timestamp_index
Purview::Indices::Simple.new(updated_timestamp_column)
end
|
#window_size ⇒ Object
39
40
41
|
# File 'lib/purview/tables/base_syncable.rb', line 39
def window_size
opts[:window_size] || (60 * 60)
end
|