11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/webhookdb/tasks/regress.rb', line 11
def initialize
super()
namespace :regress do
desc "Creates databases for all orgs that do not have them."
task :prepare do
Webhookdb.load_app
Webhookdb::Organization.where(readonly_connection_url_raw: nil).each do |org|
org.prepare_database_connections
org.migrate_replication_tables
end
end
desc "Prints out all service integrations that have untrimmed logged webhooks."
task :list_available do
Webhookdb.load_app
opaque_ids = Webhookdb::LoggedWebhook.where(truncated_at: nil).
distinct(:service_integration_opaque_id).
select_map(:service_integration_opaque_id)
sints = Webhookdb::ServiceIntegration.where(opaque_id: opaque_ids).all
self.print_service_integrations(sints)
end
desc "Replay the last :count webhooks going to the service integration with the given opaque id. " \
"Use -1 for all webhooks."
task :replay, [:opaque_id, :count] do |_, args|
opaque_id = args.fetch(:opaque_id)
count = args.fetch(:count).to_i
Webhookdb.load_app
ds = Webhookdb::LoggedWebhook.where(truncated_at: nil).
where(service_integration_opaque_id: opaque_id).
order(Sequel.asc(:inserted_at))
ds = ds.limit(count) if count >= 0
ds.paged_each do |lw|
good = lw.retry_one
puts "#{lw.pk} failed" unless good
end
end
desc "Prints out all service integrations that have backfill info available."
task :list_backfill do
Webhookdb.load_app
sints = Webhookdb::ServiceIntegration.exclude(backfill_key: nil).all
self.print_service_integrations(sints)
end
desc "Runs a backfill for the service integration with the given opaque id. " \
"Regression backfills are limited to one page."
task :backfill, [:opaque_id] do |_, args|
opaque_id = args.fetch(:opaque_id)
Webhookdb.load_app
sint = Webhookdb::ServiceIntegration[opaque_id:] or raise "No service integration for #{opaque_id}"
bfjob = Webhookdb::BackfillJob.create_recursive(service_integration: sint, incremental: false)
sint.replicator.backfill(bfjob)
end
end
end
|