Merge migrations, code fixes [SCI-5800]

This commit is contained in:
Martin Artnik 2021-07-22 10:51:03 +02:00
parent 3662365cac
commit 4bb080c25b
6 changed files with 17 additions and 25 deletions

View file

@ -63,7 +63,7 @@ class Activity < ApplicationRecord
breadcrumbs: {}
)
after_create :dispatch_webhooks
after_create ->(activity) { Activities::DispatchWebhooksJob.perform_later(activity) }
def self.activity_types_list
activity_list = type_ofs.map do |key, value|
@ -153,8 +153,4 @@ class Activity < ApplicationRecord
def activity_version
errors.add(:activity, 'wrong combination of associations') if (experiment_id || my_module_id) && subject
end
def dispatch_webhooks
Activities::DispatchWebhooksJob.perform_later(self)
end
end

View file

@ -42,7 +42,7 @@ class WebhookService
def log_error!(message)
error_count = @webhook.error_count + 1
@webhook.update(
@webhook.update!(
error_count: error_count,
last_error: message
)
@ -51,6 +51,6 @@ class WebhookService
def disable_webhook_if_broken!
return if @webhook.error_count < DISABLE_WEBHOOK_ERROR_THRESHOLD
@webhook.update(active: false)
@webhook.update!(active: false)
end
end

View file

@ -1,8 +0,0 @@
# frozen_string_literal: true
class AddErrorInfoToWebhooks < ActiveRecord::Migration[6.1]
def change
add_column :webhooks, :error_count, :integer, default: 0, null: false
add_column :webhooks, :last_error, :text
end
end

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class AddErrorInfoToWebhooksAndRenameMethodColumn < ActiveRecord::Migration[6.1]
def change
change_table :webhooks, bulk: true do |t|
t.integer :error_count, default: 0, null: false
t.text :last_error, :text
t.rename :method, :http_method
end
end
end

View file

@ -1,7 +0,0 @@
# frozen_string_literal: true
class RenameWebhookMethodColumn < ActiveRecord::Migration[6.1]
def change
rename_column :webhooks, :method, :http_method
end
end

View file

@ -2803,7 +2803,8 @@ CREATE TABLE public.webhooks (
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
error_count integer DEFAULT 0 NOT NULL,
last_error text
last_error text,
text text
);
@ -7351,7 +7352,6 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210506125657'),
('20210531114633'),
('20210603152345'),
('20210616071836'),
('20210617111749');
('20210616071836');