add started_at to sis_batches

refs CNVS-17788

so you can easily tell the difference between how long a batch took
vs. how long it took to start

test plan:
 * upload an SIS batch and let it run
 * when you view it via the API, it should include a started_at
   timestamp

Change-Id: I142024f82260c2ba690a950a09365e90c18cd43d
Reviewed-on: https://gerrit.instructure.com/47412
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2015-01-19 13:48:08 -07:00
parent 67ca345bbc
commit 1c8d862d34
3 changed files with 17 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,7 @@
class AddStartedAtToSisBatches < ActiveRecord::Migration
tag :predeploy
def change
add_column :sis_batches, :started_at, :datetime
end
end

View File

@ -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",