DEV: lint files and update topic_tags_changed trigger to use `default_value`
This commit is contained in:
parent
6c71dde3e1
commit
6239f6994f
|
@ -7,16 +7,16 @@ class AddTriggerOnFieldDefaultValueToTopicTagsChangedTrigger < ActiveRecord::Mig
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
topic_tags_changed_enabled_automations_without_trigger_on_field = DB.query <<~SQL
|
topic_tags_changed_enabled_automations_without_trigger_on_field = DB.query <<~SQL
|
||||||
SELECT discourse_automation_automations.*
|
SELECT discourse_automation_automations.*
|
||||||
FROM discourse_automation_automations
|
FROM discourse_automation_automations
|
||||||
WHERE discourse_automation_automations.trigger = 'topic_tags_changed'
|
WHERE discourse_automation_automations.trigger = 'topic_tags_changed'
|
||||||
AND discourse_automation_automations.enabled = TRUE
|
AND discourse_automation_automations.enabled = TRUE
|
||||||
AND NOT EXISTS
|
AND NOT EXISTS
|
||||||
(SELECT 1
|
(SELECT 1
|
||||||
FROM discourse_automation_fields
|
FROM discourse_automation_fields
|
||||||
WHERE automation_id = discourse_automation_automations.id
|
WHERE automation_id = discourse_automation_automations.id
|
||||||
AND name = 'trigger_on')
|
AND name = 'trigger_on')
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
topic_tags_changed_enabled_automations_without_trigger_on_field.each do |automation|
|
topic_tags_changed_enabled_automations_without_trigger_on_field.each do |automation|
|
||||||
DB.exec(
|
DB.exec(
|
||||||
|
@ -29,14 +29,14 @@ class AddTriggerOnFieldDefaultValueToTopicTagsChangedTrigger < ActiveRecord::Mig
|
||||||
|
|
||||||
def down
|
def down
|
||||||
trigger_on_fields = DB.query <<~SQL
|
trigger_on_fields = DB.query <<~SQL
|
||||||
SELECT discourse_automation_fields.*
|
SELECT discourse_automation_fields.*
|
||||||
FROM discourse_automation_fields
|
FROM discourse_automation_fields
|
||||||
JOIN discourse_automation_automations
|
JOIN discourse_automation_automations
|
||||||
ON discourse_automation_fields.automation_id = discourse_automation_automations.id
|
ON discourse_automation_fields.automation_id = discourse_automation_automations.id
|
||||||
WHERE discourse_automation_automations.trigger = 'topic_tags_changed'
|
WHERE discourse_automation_automations.trigger = 'topic_tags_changed'
|
||||||
AND discourse_automation_automations.enabled = TRUE
|
AND discourse_automation_automations.enabled = TRUE
|
||||||
AND discourse_automation_fields.name = 'trigger_on'
|
AND discourse_automation_fields.name = 'trigger_on'
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
trigger_on_fields.each { |field| DB.exec(<<~SQL, field_id: field.id) }
|
trigger_on_fields.each { |field| DB.exec(<<~SQL, field_id: field.id) }
|
||||||
DELETE FROM discourse_automation_fields
|
DELETE FROM discourse_automation_fields
|
||||||
|
|
|
@ -38,9 +38,9 @@ DiscourseAutomation::Triggerable.add(DiscourseAutomation::Triggers::TOPIC_TAGS_C
|
||||||
extra: {
|
extra: {
|
||||||
content: DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::MODES,
|
content: DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::MODES,
|
||||||
},
|
},
|
||||||
required: true,
|
default_value:
|
||||||
default_value: DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::TAGS_ADDED_OR_REMOVED,
|
DiscourseAutomation::Triggers::TopicTagsChanged::TriggerOn::TAGS_ADDED_OR_REMOVED,
|
||||||
|
required: true
|
||||||
field :trigger_with_pms, component: :boolean
|
field :trigger_with_pms, component: :boolean
|
||||||
|
|
||||||
placeholder :topic_url
|
placeholder :topic_url
|
||||||
|
|
Loading…
Reference in New Issue