Skip to content

Instantly share code, notes, and snippets.

@kgarfinkel
Created November 16, 2017 22:48
Show Gist options
  • Save kgarfinkel/d27eb8b500db26b35fc2e243549aad07 to your computer and use it in GitHub Desktop.
Save kgarfinkel/d27eb8b500db26b35fc2e243549aad07 to your computer and use it in GitHub Desktop.
received_request_conditions = {
update_type: {
source: 'update_type',
operator: 'is',
value: ['Create']
},
status_id: {
source: 'status_id',
operator: 'is_not',
value: ['3']
},
ticket_is_public: {
source: 'ticket_is_public',
operator: 'is',
value: ['public']
}
}
received_request_action = {
source: 'notification_user',
value: ["requester_id", "[Request received] {{ticket.title}}", "Your request ({{ticket.id}}) has been received and is being reviewed by our support staff.\n\nTo add additional comments, reply to this email.\n\n{{ticket.comments_formatted}}"]
}
comment_update_conditions = {
update_type: {
source: 'update_type',
operator: 'is',
value: ['Change']
},
comment_is_public: {
source: 'comment_is_public',
operator: 'is',
value: ['requester_can_see_comment']
},
comment_is_public: {
source: 'comment_is_public',
operator: 'is',
value: ['requester_can_see_comment']
}
}
commment_update_action = {
source: 'notification_user',
operator: 'is'
value: ["requester_id", "[{{ticket.account}}] Re: {{ticket.title}}", "Your request ({{ticket.id}}) has been updated. To add additional comments, reply to this email.\n{{ticket.comments_formatted}}"]
}
account_ids = {
one: [],
two: [],
two_plus: [],
none: []
}
def match_updated_type
end
#ActiveRecord::Base.on_all_shards do |shard_id|
Account.all.each do |account|
triggers = Trigger.where(account_id: account.id)
match_count = 0
triggers.each do |trigger|
definition = trigger.definition
conditions_all = definition.conditions_all
next unless conditions_all.length == 3
conditions_all.any? do |condition|
updated_type = system_conditions[:update_type]
condition.instance_variable_get(:@source) == updated_type[:source] &&
condition.instance_variable_get(:@operator) == updated_type[:operator] &&
condition.instance_variable_get(:@value) == updated_type[:value]
end
two = conditions_all.any? do |condition|
updated_type = system_conditions[:status_id]
condition.instance_variable_get(:@source) == updated_type[:source] &&
condition.instance_variable_get(:@operator) == updated_type[:operator] &&
condition.instance_variable_get(:@value) == updated_type[:value]
end
next unless result
account_ids[:one] << account.id
account_ids[:two] << account.id
end
end
#end
puts account_ids.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment