From 6239f6994f9bd2218ff4f92395a038aa37c3004d Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Tue, 24 Dec 2024 12:06:59 -0300 Subject: [PATCH] DEV: lint files and update topic_tags_changed trigger to use `default_value` --- ...ult_value_to_topic_tags_changed_trigger.rb | 36 +++++++++---------- .../triggers/topic_tags_changed.rb | 6 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/plugins/automation/db/migrate/20241219222326_add_trigger_on_field_default_value_to_topic_tags_changed_trigger.rb b/plugins/automation/db/migrate/20241219222326_add_trigger_on_field_default_value_to_topic_tags_changed_trigger.rb index ffd4362728c..69342c79d32 100644 --- a/plugins/automation/db/migrate/20241219222326_add_trigger_on_field_default_value_to_topic_tags_changed_trigger.rb +++ b/plugins/automation/db/migrate/20241219222326_add_trigger_on_field_default_value_to_topic_tags_changed_trigger.rb @@ -7,16 +7,16 @@ class AddTriggerOnFieldDefaultValueToTopicTagsChangedTrigger < ActiveRecord::Mig SQL topic_tags_changed_enabled_automations_without_trigger_on_field = DB.query <<~SQL - SELECT discourse_automation_automations.* - FROM discourse_automation_automations - WHERE discourse_automation_automations.trigger = 'topic_tags_changed' - AND discourse_automation_automations.enabled = TRUE - AND NOT EXISTS - (SELECT 1 - FROM discourse_automation_fields - WHERE automation_id = discourse_automation_automations.id - AND name = 'trigger_on') - SQL + SELECT discourse_automation_automations.* + FROM discourse_automation_automations + WHERE discourse_automation_automations.trigger = 'topic_tags_changed' + AND discourse_automation_automations.enabled = TRUE + AND NOT EXISTS + (SELECT 1 + FROM discourse_automation_fields + WHERE automation_id = discourse_automation_automations.id + AND name = 'trigger_on') + SQL topic_tags_changed_enabled_automations_without_trigger_on_field.each do |automation| DB.exec( @@ -29,14 +29,14 @@ class AddTriggerOnFieldDefaultValueToTopicTagsChangedTrigger < ActiveRecord::Mig def down trigger_on_fields = DB.query <<~SQL - SELECT discourse_automation_fields.* - FROM discourse_automation_fields - JOIN discourse_automation_automations - ON discourse_automation_fields.automation_id = discourse_automation_automations.id - WHERE discourse_automation_automations.trigger = 'topic_tags_changed' - AND discourse_automation_automations.enabled = TRUE - AND discourse_automation_fields.name = 'trigger_on' - SQL + SELECT discourse_automation_fields.* + FROM discourse_automation_fields + JOIN discourse_automation_automations + ON discourse_automation_fields.automation_id = discourse_automation_automations.id + WHERE discourse_automation_automations.trigger = 'topic_tags_changed' + AND discourse_automation_automations.enabled = TRUE + AND discourse_automation_fields.name = 'trigger_on' + SQL trigger_on_fields.each { |field| DB.exec(<<~SQL, field_id: field.id) } DELETE FROM discourse_automation_fields diff --git a/plugins/automation/lib/discourse_automation/triggers/topic_tags_changed.rb b/plugins/automation/lib/discourse_automation/triggers/topic_tags_changed.rb index 5eb6a83c809..9cbd5ce119b 100644 --- a/plugins/automation/lib/discourse_automation/triggers/topic_tags_changed.rb +++ b/plugins/automation/lib/discourse_automation/triggers/topic_tags_changed.rb @@ -38,9 +38,9 @@ DiscourseAutomation::Triggerable.add(DiscourseAutomation::Triggers::TOPIC_TAGS_C extra: { content: DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::MODES, }, - required: true, - default_value: DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::TAGS_ADDED_OR_REMOVED, - + default_value: + DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::TAGS_ADDED_OR_REMOVED, + required: true field :trigger_with_pms, component: :boolean placeholder :topic_url