Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the "skip_agent" option from EventFormattingAgent.
It is now possible to include an agent name without the special flag just by putting `"agent" => "{{agent.type}}"` in "instructions". This commit includes automatic migration.
- Loading branch information
Showing
2 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class ConvertEfaSkipAgent < ActiveRecord::Migration | ||
def up | ||
Agent.where(type: 'Agents::EventFormattingAgent').each do |agent| | ||
agent.options_will_change! | ||
unless agent.options.delete('skip_agent').to_s == 'true' | ||
agent.options['instructions'] = { | ||
'agent' => '{{agent.type}}' | ||
}.update(agent.options['instructions'] || {}) | ||
end | ||
agent.save! | ||
end | ||
end | ||
|
||
def down | ||
Agent.where(type: 'Agents::EventFormattingAgent').each do |agent| | ||
agent.options_will_change! | ||
agent.options['skip_agent'] = (agent.options['instructions'] || {})['agent'] == '{{agent.type}}' | ||
agent.save! | ||
end | ||
end | ||
end |