@@ -40,6 +40,7 @@ def verify(csv, verify)
4040 # course_id,short_name,long_name,account_id,term_id,status
4141 def process ( csv )
4242 start = Time . now
43+ courses_to_update_sis_batch_id = [ ]
4344 FasterCSV . foreach ( csv [ :fullpath ] , :headers => :first_row , :skip_blanks => true , :header_converters => :downcase ) do |row |
4445 update_progress
4546
@@ -71,7 +72,6 @@ def process(csv)
7172 course . name = course . sis_name = row [ 'long_name' ]
7273 end
7374 course . sis_source_id = row [ 'course_id' ]
74- course . sis_batch_id = @batch . id if @batch
7575 if row [ 'status' ] =~ /active/i
7676 if course . workflow_state == 'completed'
7777 course . workflow_state = 'available'
@@ -91,12 +91,18 @@ def process(csv)
9191 add_warning ( csv , "Bad date format for course #{ row [ 'course_id' ] } " )
9292 end
9393
94- course . save_without_broadcasting!
94+ if course . changed?
95+ course . sis_batch_id = @batch . id if @batch
96+ course . save_without_broadcasting!
97+ elsif @batch
98+ courses_to_update_sis_batch_id << @batch . id
99+ end
95100 @sis . counts [ :courses ] += 1
96101
97102 course . update_account_associations if update_account_association
98103 end
99104 end
105+ Course . update_all ( { :sis_batch_id => @batch . id } , { :id => courses_to_update_sis_batch_id } ) if @batch && !courses_to_update_sis_batch_id . empty?
100106 logger . debug ( "Courses took #{ Time . now - start } seconds" )
101107 end
102108
0 commit comments