Class: Webhookdb::Replicator::TransistorEpisodeStatsV1
- Inherits:
-
Base
- Object
- Base
- Webhookdb::Replicator::TransistorEpisodeStatsV1
show all
- Includes:
- Appydays::Loggable, TransistorV1Mixin
- Defined in:
- lib/webhookdb/replicator/transistor_episode_stats_v1.rb
Defined Under Namespace
Classes: EpisodeStatsBackfiller
Constant Summary
collapse
- CONV_PARSE_DMY_DASH =
Webhookdb::Replicator::Column::IsomorphicProc.new(
ruby: lambda do |s, **_|
return Date.strptime(s, "%d-%m-%Y")
rescue TypeError, Date::Error
return nil
end,
sql: ->(e) { Sequel.function(:to_date, e, "DD-MM-YYYY") },
)
- CONV_REMOTE_KEY =
Webhookdb::Replicator::Column::IsomorphicProc.new(
ruby: ->(_, resource:, **_) { "#{resource.fetch('episode_id')}-#{resource.fetch('date')}" },
sql: ->(_) { Sequel.lit("'do not use'") },
)
DBAdapter::ColumnTypes::BIGINT, DBAdapter::ColumnTypes::BIGINT_ARRAY, DBAdapter::ColumnTypes::BOOLEAN, DBAdapter::ColumnTypes::COLUMN_TYPES, DBAdapter::ColumnTypes::DATE, DBAdapter::ColumnTypes::DECIMAL, DBAdapter::ColumnTypes::DOUBLE, DBAdapter::ColumnTypes::FLOAT, DBAdapter::ColumnTypes::INTEGER, DBAdapter::ColumnTypes::INTEGER_ARRAY, DBAdapter::ColumnTypes::OBJECT, DBAdapter::ColumnTypes::TEXT, DBAdapter::ColumnTypes::TEXT_ARRAY, DBAdapter::ColumnTypes::TIMESTAMP, DBAdapter::ColumnTypes::UUID
Constants inherited
from Base
Base::MAX_INDEX_NAME_LENGTH
Instance Attribute Summary
Attributes inherited from Base
#service_integration
Class Method Summary
collapse
Instance Method Summary
collapse
#_verify_backfill_401_err_msg, #_verify_backfill_err_msg, #_webhook_response
Methods inherited from Base
#_any_subscriptions_to_notify?, #_backfill_state_change_fields, #_clear_backfill_information, #_clear_webook_information, #_coalesce_excluded_on_update, #_enqueue_backfill_jobs, #_extra_index_specs, #_fetch_enrichment, #_find_dependency_candidate, #_notify_dependents, #_parallel_backfill, #_prepare_for_insert, #_publish_rowupsert, #_resource_to_data, #_store_enrichment_body?, #_to_json, #_upsert_update_expr, #_upsert_webhook, #_verify_backfill_err_msg, #_webhook_response, #_webhook_state_change_fields, #admin_dataset, #backfill, #backfill_not_supported_message, #calculate_and_backfill_state_machine, #calculate_dependency_state_machine_step, #calculate_preferred_create_state_machine, #calculate_webhook_state_machine, chunked_row_update_bounds, #clear_backfill_information, #clear_webhook_information, #create_table, #create_table_modification, #data_column, #dbadapter_table, #denormalized_columns, #descriptor, #dispatch_request_to, #documentation_url, #enqueue_sync_targets, #enrichment_column, #ensure_all_columns, #ensure_all_columns_modification, #find_dependent, #find_dependent!, #indices, #initialize, #preferred_create_state_machine_method, #preprocess_headers_for_logging, #primary_key_column, #process_state_change, #process_webhooks_synchronously?, #qualified_table_sequel_identifier, #readonly_dataset, #remote_key_column, #requires_sequence?, #resource_name_plural, #resource_name_singular, #schema_and_table_symbols, #storable_columns, #synchronous_processing_response_body, #timestamp_column, #upsert_has_deps?, #upsert_webhook, #upsert_webhook_body, #verify_backfill_credentials, #webhook_endpoint, #webhook_response
Instance Method Details
#_backfillers ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 82
def _backfillers
episode_svc = self.service_integration.depends_on.replicator
backfillers = episode_svc.admin_dataset(timeout: :fast) do |episode_ds|
episode_ds.select(:transistor_id, :created_at).map do |episode|
EpisodeStatsBackfiller.new(
episode_svc:,
episode_stats_svc: self,
episode_id: episode[:transistor_id],
episode_created_at: episode[:created_at],
)
end
end
return backfillers
end
|
#_denormalized_columns ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 49
def _denormalized_columns
return [
Webhookdb::Replicator::Column.new(:episode_id, TEXT),
Webhookdb::Replicator::Column.new(:date, DATE, converter: CONV_PARSE_DMY_DASH),
Webhookdb::Replicator::Column.new(:downloads, INTEGER),
Webhookdb::Replicator::Column.new(:row_updated_at, TIMESTAMP, defaulter: :now, optional: true),
]
end
|
#_remote_key_column ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 38
def _remote_key_column
return Webhookdb::Replicator::Column.new(
:compound_identity,
TEXT,
data_key: "<compound key, see converter>",
index: true,
optional: true,
converter: CONV_REMOTE_KEY,
)
end
|
#_resource_and_event(request) ⇒ Object
62
63
64
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 62
def _resource_and_event(request)
return request.body, nil
end
|
#_timestamp_column_name ⇒ Object
58
59
60
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 58
def _timestamp_column_name
return :row_updated_at
end
|
#_update_where_expr ⇒ Object
66
67
68
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 66
def _update_where_expr
return self.qualified_table_sequel_identifier[:downloads] !~ Sequel[:excluded][:downloads]
end
|
#calculate_backfill_state_machine ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 70
def calculate_backfill_state_machine
if (step = self.calculate_dependency_state_machine_step(dependency_help: ""))
return step
end
step = Webhookdb::Replicator::StateMachineStep.new
step.output = %(Great! That's all the information we need.
When your Transistor Episodes get added or updated, their stats will be updated in WebhookDB too.
#{self._query_help_output})
return step.completed
end
|
#on_dependency_webhook_upsert(_replicator, _payload) ⇒ Object
138
139
140
|
# File 'lib/webhookdb/replicator/transistor_episode_stats_v1.rb', line 138
def on_dependency_webhook_upsert(_replicator, _payload, *)
return
end
|