canvas_sync 0.17.36 → 0.17.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync/engine.rb +6 -0
- data/lib/canvas_sync/generators/templates/migrations/create_users.rb +0 -1
- data/lib/canvas_sync/importers/bulk_importer.rb +8 -1
- data/lib/canvas_sync/job_batches/jobs/base_job.rb +1 -1
- data/lib/canvas_sync/job_batches/jobs/managed_batch_job.rb +2 -2
- data/lib/canvas_sync/job_batches/pool.rb +2 -2
- data/lib/canvas_sync/job_batches/sidekiq.rb +15 -12
- data/lib/canvas_sync/processors/model_mappings.yml +1 -0
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/log/test.log +12888 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b77546f58b3db164d3121fecdfb6de07d708e46a7673d7abeee45682d5390b45
|
4
|
+
data.tar.gz: c4ca76da8b99d56c2a1d9db6f9ef9be793ee0f74ca3ef4f59ad494f67f8a596c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1e655a7e5a202dd13a80f650538c6576c2998a15e35334fda932cf4b49485ad0cf5be2de2e79458f71e317cd21380375876c5cc5b3d7c5858e6071468b4421f
|
7
|
+
data.tar.gz: c1f5c91a3f01429fc0f588240f83003e78a46d8de29ce64020b7c36d2c7d582cd4b6f66743ab4f6c2c0be443ae9f32650e48d35a36434a1bb85d2636d371b84c
|
data/lib/canvas_sync/engine.rb
CHANGED
@@ -5,6 +5,12 @@ module CanvasSync
|
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
isolate_namespace CanvasSync
|
7
7
|
|
8
|
+
initializer "canvas_sync.serialze_symbols" do |app|
|
9
|
+
app.config.active_record.yaml_column_permitted_classes ||= []
|
10
|
+
app.config.active_record.yaml_column_permitted_classes |= [Symbol]
|
11
|
+
rescue
|
12
|
+
end
|
13
|
+
|
8
14
|
initializer :append_migrations do |app|
|
9
15
|
config.paths["db/migrate"].expanded.each do |expanded_path|
|
10
16
|
app.config.paths["db/migrate"] << expanded_path
|
@@ -23,7 +23,14 @@ module CanvasSync
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.perform_in_batches(report_file_path,
|
26
|
+
def self.perform_in_batches(report_file_path, raw_mapping, klass, conflict_target, import_args: {})
|
27
|
+
mapping = {}.with_indifferent_access
|
28
|
+
raw_mapping.each do |db_col, opts|
|
29
|
+
next if opts[:deprecated] && !klass.column_names.include?(db_col.to_s)
|
30
|
+
|
31
|
+
mapping[db_col] = opts
|
32
|
+
end
|
33
|
+
|
27
34
|
csv_column_names = mapping.values.map { |value| value[:report_column].to_s }
|
28
35
|
database_column_names = mapping.keys
|
29
36
|
|
@@ -26,7 +26,7 @@ module CanvasSync
|
|
26
26
|
|
27
27
|
mapped_sub_jobs = sub_jobs.each_with_index.map do |j, i|
|
28
28
|
j['_mngbid_index_'] = i # This allows duplicate jobs when a Redis Set is used
|
29
|
-
j = ActiveJob::Arguments.serialize([j])
|
29
|
+
j = ::ActiveJob::Arguments.serialize([j])
|
30
30
|
JSON.unparse(j)
|
31
31
|
end
|
32
32
|
if ordered
|
@@ -104,7 +104,7 @@ module CanvasSync
|
|
104
104
|
return unless next_job_json.present?
|
105
105
|
|
106
106
|
next_job = JSON.parse(next_job_json)
|
107
|
-
next_job = ActiveJob::Arguments.deserialize(next_job)[0]
|
107
|
+
next_job = ::ActiveJob::Arguments.deserialize(next_job)[0]
|
108
108
|
|
109
109
|
Batch.new(root_bid).jobs do
|
110
110
|
Batch.new.tap do |batch|
|
@@ -171,7 +171,7 @@ module CanvasSync
|
|
171
171
|
jobs_key = "#{redis_key}-jobs"
|
172
172
|
# This allows duplicate jobs when a Redis Set is used
|
173
173
|
job_desc[:_pool_random_key_] = SecureRandom.urlsafe_base64(10)
|
174
|
-
job_json = JSON.unparse(ActiveJob::Arguments.serialize([job_desc]))
|
174
|
+
job_json = JSON.unparse(::ActiveJob::Arguments.serialize([job_desc]))
|
175
175
|
order = self.order
|
176
176
|
|
177
177
|
redis.multi do |r|
|
@@ -204,7 +204,7 @@ module CanvasSync
|
|
204
204
|
|
205
205
|
return nil unless job_json.present?
|
206
206
|
|
207
|
-
ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
207
|
+
::ActiveJob::Arguments.deserialize(JSON.parse(job_json))[0]&.symbolize_keys
|
208
208
|
end
|
209
209
|
|
210
210
|
def self.redis(&blk)
|
@@ -76,11 +76,21 @@ module CanvasSync
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.is_activejob_job?(msg)
|
79
|
-
return false unless defined?(ActiveJob)
|
79
|
+
return false unless defined?(::ActiveJob)
|
80
80
|
|
81
81
|
msg['class'] == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' && (msg['wrapped'].to_s).constantize < JobBatches::ActiveJob::BatchAwareJob
|
82
82
|
end
|
83
83
|
|
84
|
+
def self.switch_tenant(job)
|
85
|
+
if defined?(::Apartment)
|
86
|
+
::Apartment::Tenant.switch(job['apartment'] || 'public') do
|
87
|
+
yield
|
88
|
+
end
|
89
|
+
else
|
90
|
+
yield
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
84
94
|
def self.configure
|
85
95
|
if defined?(::Sidekiq::Batch) && ::Sidekiq::Batch != JobBatches::Batch
|
86
96
|
print "WARNING: Detected Sidekiq Pro or sidekiq-batch. CanvasSync JobBatches may not be fully compatible!"
|
@@ -104,19 +114,12 @@ module CanvasSync
|
|
104
114
|
end
|
105
115
|
|
106
116
|
config.death_handlers << ->(job, ex) do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
return unless job['bid'].present?
|
113
|
-
|
114
|
-
if defined?(::Apartment)
|
115
|
-
::Apartment::Tenant.switch(job['apartment'] || 'public') do
|
117
|
+
switch_tenant(job) do
|
118
|
+
if is_activejob_job?(job)
|
119
|
+
JobBatches::ActiveJob.handle_job_death(job["args"][0], ex)
|
120
|
+
elsif job['bid'].present?
|
116
121
|
::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
|
117
122
|
end
|
118
|
-
else
|
119
|
-
::Sidekiq::Batch.process_dead_job(job['bid'], job['jid'])
|
120
123
|
end
|
121
124
|
end
|
122
125
|
end
|
data/lib/canvas_sync/version.rb
CHANGED