From e28b4430bc5d9e9b9ec9d801b488f5254ddbfa11 Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Thu, 29 Dec 2016 10:16:15 -0600 Subject: [PATCH] if_statement --> _if migration --- .ruby-version | 2 +- api_docs.md.erb | 2 +- app/lib/sequence_migration/update_if_statement.rb | 12 +++++++++++- app/models/sequence.rb | 6 +++++- app/mutations/tool_slots/batch_update.rb | 3 +-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.ruby-version b/.ruby-version index f90b1afc0..0bee604df 100755 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.2 +2.3.3 diff --git a/api_docs.md.erb b/api_docs.md.erb index 59417e648..45452778d 100644 --- a/api_docs.md.erb +++ b/api_docs.md.erb @@ -5,7 +5,7 @@ ``` <%= - JSON.pretty_generate(request.params.except(:controller, :action, :format, :id)) + JSON.pretty_generate(request.params.except(:controller, :action, :format, :id, :user_id, :device_id)) %> ``` <% end %> diff --git a/app/lib/sequence_migration/update_if_statement.rb b/app/lib/sequence_migration/update_if_statement.rb index ded11d7f1..df0a287b1 100644 --- a/app/lib/sequence_migration/update_if_statement.rb +++ b/app/lib/sequence_migration/update_if_statement.rb @@ -15,7 +15,17 @@ module SequenceMigration .body .select { |x| x["kind"] == "if_statement" } .each do |x| - binding.pry + x["kind"] = "_if" + x["args"] = { + "lhs": x["args"]["lhs"], + "rhs": x["args"]["rhs"], + "op": x["args"]["op"], + "_then": { + "kind": "execute", + "args": { "sub_sequence_id": x["args"]["sub_sequence_id"] } + }, + "_else": { "kind": "nothing", "args": {} } + } end end end diff --git a/app/models/sequence.rb b/app/models/sequence.rb index 3e47df0ac..970ab2f4d 100644 --- a/app/models/sequence.rb +++ b/app/models/sequence.rb @@ -37,8 +37,12 @@ class Sequence < ActiveRecord::Base # Helper used for QAing stuff on staging. Grabs a random sequence from the # database, runs a migration (does not save) and prints to screen. def self.spot_check - s = Sequence.order("RANDOM()").first + s = random puts "Sequence ##{s.id} =========" puts s.maybe_migrate.body.to_yaml end + + def self.random + Sequence.order("RANDOM()").first + end end diff --git a/app/mutations/tool_slots/batch_update.rb b/app/mutations/tool_slots/batch_update.rb index 2ef091122..b16102d8d 100644 --- a/app/mutations/tool_slots/batch_update.rb +++ b/app/mutations/tool_slots/batch_update.rb @@ -33,5 +33,4 @@ module ToolSlots ts.update_attributes!(params) && ts end end - end - +end