@@ -394,21 +394,23 @@ def assign_issue_attrs(issue, category, fixed_version_id, assigned_to, status, r
394
394
issue . tracker_id = tracker . present? ? tracker . id : issue . tracker_id
395
395
396
396
# optional attributes
397
- issue . description = fetch ( "description" , row ) || issue . description
398
- issue . category_id = category != nil ? category . id : issue . category_id
397
+ issue . description = fetch ( "description" , row )
398
+ issue . category_id = category . try ( :id )
399
399
400
- if fetch ( "start_date" , row ) . present?
401
- issue . start_date = Date . parse ( fetch ( "start_date" , row ) )
400
+ [ "start_date" , "due_date" ] . each do |date_field_name |
401
+ date_field_value = fetch ( date_field_name , row )
402
+
403
+ if date_field_value . present?
404
+ issue . send ( "#{ date_field_name } =" , Date . parse ( date_field_value ) )
405
+ else
406
+ issue . send ( "#{ date_field_name } =" , nil )
407
+ end
402
408
end
403
- issue . due_date = if row [ @attrs_map [ "due_date" ] ] . blank?
404
- nil
405
- else
406
- Date . parse ( row [ @attrs_map [ "due_date" ] ] )
407
- end
408
- issue . assigned_to_id = assigned_to . id if assigned_to
409
- issue . fixed_version_id = fixed_version_id if fixed_version_id
410
- issue . done_ratio = row [ @attrs_map [ "done_ratio" ] ] || issue . done_ratio
411
- issue . estimated_hours = row [ @attrs_map [ "estimated_hours" ] ] || issue . estimated_hours
409
+
410
+ issue . assigned_to_id = assigned_to . try ( :id )
411
+ issue . fixed_version_id = fixed_version_id
412
+ issue . done_ratio = fetch ( "done_ratio" , row )
413
+ issue . estimated_hours = fetch ( "estimated_hours" , row )
412
414
issue . is_private = ( convert_to_boolean ( fetch ( "is_private" , row ) ) || false )
413
415
end
414
416
@@ -489,18 +491,23 @@ def handle_custom_fields(add_versions, issue, project, row)
489
491
h [ cf . id ] = process_multivalue_custom_field ( project , add_versions , issue , cf , value )
490
492
else
491
493
begin
492
- value = case cf . field_format
493
- when 'user'
494
- user_id_for_login! ( value ) . to_s
495
- when 'version'
496
- version_id_for_name! ( project , value , add_versions ) . to_s
497
- when 'date'
498
- value . to_date . to_s ( :db )
499
- when 'bool'
500
- convert_to_0_or_1 ( value )
501
- else
502
- value
503
- end
494
+ if value . present?
495
+ value = case cf . field_format
496
+ when 'user'
497
+ user_id_for_login! ( value ) . to_s
498
+ when 'version'
499
+ version_id_for_name! ( project , value , add_versions ) . to_s
500
+ when 'date'
501
+ value . to_date . to_s ( :db )
502
+ when 'bool'
503
+ convert_to_0_or_1 ( value )
504
+ else
505
+ value
506
+ end
507
+ else
508
+ value = nil
509
+ end
510
+
504
511
h [ cf . id ] = value
505
512
rescue
506
513
if custom_failed_count == 0
0 commit comments