canvas_sync 0.17.18 → 0.17.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30e1a16308bbc8795dc671c19f35d29577665213261829d3180a9efeefab4adf
4
- data.tar.gz: bade0d8907b22bf252b85ba4067798ebd3b6582deed06adfccf7a8951a6164b4
3
+ metadata.gz: d995ce469310b7b54158745305c968edd4c7a910bcad87891ffabfa29cd22a30
4
+ data.tar.gz: 83a0bb75ceb290402137f2531e1925d4872a0e272fcabf75a6c3451b3de5f721
5
5
  SHA512:
6
- metadata.gz: 4a155b415154694a42c218bd5ef91f21ca7cdcc81967cc2f2c16a180eebfb32d1b279c72ea2eab58beaabb8e8a8905fe4ef4086ce758c9ee14b1583eccf06849
7
- data.tar.gz: 3269c39188c086e7b3b03d6280414fbdc7a32c6780af5744da08f3f9432f4eb5ed993c3af4d22e2fe477d92ca8e4d705c62ba9e9005559a9e1145922f565aa4f
6
+ metadata.gz: 9287196092064977d34259de638cfd41cf189f6dc9b6a97c6fd507d2555f8f3b0527643d38991765d56bf428856407608ef0c1834b48b6a6dd3201ed232b9879
7
+ data.tar.gz: a751ad1e08d3feb2716e41d4c552f983f2d83590321dc4d1cc2a18d2f800859587fa1884272bbdbaff0cc4aefe867c0af8f0dfb24c2dc6aba25190e7a190449a
@@ -26,7 +26,11 @@ module CanvasSync
26
26
  def self.perform_in_batches(report_file_path, mapping, klass, conflict_target, import_args: {})
27
27
  csv_column_names = mapping.keys
28
28
  database_column_names = mapping.values.map { |value| value[:database_column_name] }
29
- database_conflict_column_name = conflict_target ? mapping[conflict_target][:database_column_name] : nil
29
+
30
+ puts mapping.inspect
31
+
32
+ conflict_target = Array(conflict_target).map(&:to_sym)
33
+ database_conflict_column_name = conflict_target.map{|ct| mapping[ct][:database_column_name] }
30
34
 
31
35
  row_ids = {}
32
36
  batcher = CanvasSync::BatchProcessor.new(of: batch_size) do |batch|
@@ -35,9 +39,11 @@ module CanvasSync
35
39
  end
36
40
 
37
41
  row_buffer_out = ->(row) {
38
- if conflict_target
39
- next if row_ids[row[conflict_target]]
40
- row_ids[row[conflict_target]] = true
42
+ if conflict_target.present?
43
+ key = conflict_target.map{|ct| row[ct] }
44
+ next if row_ids[key]
45
+
46
+ row_ids[key] = true
41
47
  end
42
48
 
43
49
  formatted_row = csv_column_names.map do |column|
@@ -79,7 +85,7 @@ module CanvasSync
79
85
  condition: condition_sql(klass, columns, import_args[:sync_start_time]),
80
86
  columns: columns
81
87
  }
82
- update_conditions[:conflict_target] = conflict_target if conflict_target
88
+ update_conditions[:conflict_target] = conflict_target if conflict_target.present?
83
89
 
84
90
  options = { validate: false, on_duplicate_key_update: update_conditions }.merge(import_args)
85
91
  options.delete(:on_duplicate_key_update) if options.key?(:on_duplicate_key_ignore)
@@ -46,7 +46,7 @@ module CanvasSync
46
46
  m = Regexp.last_match
47
47
  day = m[1]
48
48
  skip = m[2] || "1"
49
- Date.new.send(:"#{day}?") && last_full_sync.end_of_day <= (skip.to_i.weeks.ago.end_of_day)
49
+ DateTime.now.send(:"#{day}?") && last_full_sync.end_of_day <= (skip.to_i.weeks.ago.end_of_day)
50
50
  when opt.match?(%r{^(\d+)\%$})
51
51
  m = Regexp.last_match
52
52
  rand(100) < m[1].to_i
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.17.18".freeze
2
+ VERSION = "0.17.19".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.18
4
+ version: 0.17.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Collings
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler