diff --git a/app/models/sis_batch.rb b/app/models/sis_batch.rb index b36b14630a8..3353ab14c3c 100644 --- a/app/models/sis_batch.rb +++ b/app/models/sis_batch.rb @@ -127,6 +127,7 @@ class SisBatch < ActiveRecord::Base if self.workflow_state == 'created' self.workflow_state = :importing self.progress = 0 + self.started_at = Time.now.utc self.save import_scheme = SisBatch.valid_import_types[self.data[:import_type]] @@ -201,7 +202,7 @@ class SisBatch < ActiveRecord::Base self.workflow_state = :failed self.workflow_state = :failed_with_messages if messages? end - self.ended_at = Time.now + self.ended_at = Time.now.utc self.save end @@ -250,6 +251,7 @@ class SisBatch < ActiveRecord::Base self.options ||= {} # set this to empty hash if it does not exist so options[:stuff] doesn't blow up data = { "created_at" => self.created_at, + "started_at" => self.started_at, "ended_at" => self.ended_at, "updated_at" => self.updated_at, "progress" => self.progress, diff --git a/db/migrate/20150119204052_add_started_at_to_sis_batches.rb b/db/migrate/20150119204052_add_started_at_to_sis_batches.rb new file mode 100644 index 00000000000..b5992c5713a --- /dev/null +++ b/db/migrate/20150119204052_add_started_at_to_sis_batches.rb @@ -0,0 +1,7 @@ +class AddStartedAtToSisBatches < ActiveRecord::Migration + tag :predeploy + + def change + add_column :sis_batches, :started_at, :datetime + end +end diff --git a/spec/apis/v1/sis_imports_api_spec.rb b/spec/apis/v1/sis_imports_api_spec.rb index 22dbe02898f..a2ae5e69963 100644 --- a/spec/apis/v1/sis_imports_api_spec.rb +++ b/spec/apis/v1/sis_imports_api_spec.rb @@ -52,6 +52,8 @@ describe SisImportsApiController, type: :request do json.delete("updated_at") expect(json.has_key?("ended_at")).to be_truthy json.delete("ended_at") + expect(json.has_key?("started_at")).to eq true + json.delete("started_at") if opts[:batch_mode_term_id] expect(json["batch_mode_term_id"]).not_to be_nil end @@ -87,6 +89,8 @@ describe SisImportsApiController, type: :request do json.delete("updated_at") expect(json.has_key?("ended_at")).to be_truthy json.delete("ended_at") + expect(json.has_key?("started_at")).to eq true + json.delete("started_at") batch = SisBatch.last expect(json).to eq({ "data" => { "import_type"=>"instructure_csv"}, @@ -115,6 +119,8 @@ describe SisImportsApiController, type: :request do json.delete("updated_at") expect(json.has_key?("ended_at")).to be_truthy json.delete("ended_at") + expect(json.has_key?("started_at")).to eq true + json.delete("started_at") expect(json).to eq({ "data" => { "import_type" => "instructure_csv", "supplied_batches" => ["user"], @@ -499,6 +505,7 @@ describe SisImportsApiController, type: :request do json["sis_imports"].first.delete("created_at") json["sis_imports"].first.delete("updated_at") json["sis_imports"].first.delete("ended_at") + json["sis_imports"].first.delete("started_at") expect(json).to eq({"sis_imports"=>[{ "data" => { "import_type" => "instructure_csv",